Skip to content

Replace flake8 and pycodestyle with ruff#131

Merged
un33k merged 5 commits intoun33k:masterfrom
cclauss:ruff
Oct 9, 2023
Merged

Replace flake8 and pycodestyle with ruff#131
un33k merged 5 commits intoun33k:masterfrom
cclauss:ruff

Conversation

@cclauss
Copy link
Copy Markdown
Contributor

@cclauss cclauss commented Mar 5, 2023

Ruff supports over 500 lint rules including bandit, flake8, isort, pylint, and pyupgrade and is written in Rust for speed.
Also added rules for pylint conventions, pylint errors, and pylint warnings.

@mrezzamoradi
Copy link
Copy Markdown
Collaborator

This is actually nice. The difference in speed is noticeable.

@jdevera
Copy link
Copy Markdown
Collaborator

jdevera commented Aug 13, 2023

Thank you for this PR!
Let's say there is an appetite for this particular change.
For the PR to be merged, though, there would be a few things to take care of, please let me know if you are happy to take them on:

  1. Ensure a 1-1 correspondence between the current settings and the new ones with ruff. In his case, the command introduces a line length limit of 117 whereas this project explicitly disables line length checks currently. Generally, these changes should not be introduced without mentioning them explicitly.
  2. Run the command on the repo and contribute also the changes that will fix violations. In his case, two violations appear, and this would result in an immediate CI failure upon merging this PR.
  3. Also change non-functional code that refers to the changes you are making. There is a title for the step you are changing that refers to flake8 and should not. But also there are other places in the repo that refer to the tools you are replacing, like the dev.requirements file and the format.sh script

@cclauss
Copy link
Copy Markdown
Contributor Author

cclauss commented Aug 15, 2023

this project explicitly disables line length checks currently

Disabling line length checks (and code complexity checks) is a bad idea because it encourages further bad behavior. If instead we set an upper limit then if someone wants to contribute longer lines (or more complex code) then they need to justify in their pull request why they need messier code then is already in the codebase.

contribute also the changes that will fix violations

Rome was not built it a day. A pull request that improves the codebase by setting up guardrails moves the project forward. Fixing the two ignored issues will make for a much more complicated pull request to get reviewed and merged. Given that this pull request has taken more than 5 months to get reviewed, keeping the changes simple is goodness.

other places in the repo that refer to the tools you are replacing, like the dev.requirements file and the format.sh script

This GitHub Action does not use dev.requirements and ruff is not a code formatter. Black is.

@un33k
Copy link
Copy Markdown
Owner

un33k commented Aug 15, 2023

Contributors/Collaborators - Please feel free to approve and merge.

One question: Do we need to ensure 'ruff' is installed on all systems without it being in the requirements.txt

@cclauss
Copy link
Copy Markdown
Contributor Author

cclauss commented Aug 15, 2023

Do we need to ensure 'ruff' is installed on all systems without it being in the requirements.txt

Perhaps ruff and black and similar tools should be run in pre-commit to ensure the same versions are installed on all contributing and testing machines.

@jdevera
Copy link
Copy Markdown
Collaborator

jdevera commented Aug 19, 2023

Fixing the two ignored issues will make for a much more complicated pull request to get reviewed and merged.

My bad, I did not mean the ignored issues, but it was a misunderstanding coming 100% from me. My working tree was dirty, and the command caught some errors in some experimental test files I had around. No real issues here.

Given that this pull request has taken more than 5 months to get reviewed, keeping the changes simple is goodness.

Regardless of the misunderstanding, I believe the time it takes to review PRs here depends more on the availability of the maintainers than on anything else.

Do we need to ensure 'ruff' is installed on all systems without it being in the requirements.txt

I would add a line to the dev.requirements.txt, with a specific version, and I think this PR would benefit from locking on the version of ruff in the workflow file too.

RE: the line length check. I'm all for it and this could then be the last time two humans have a conversation about such a boring topic on this repo 🥂 .

@un33k un33k merged commit 59eb957 into un33k:master Oct 9, 2023
@cclauss cclauss deleted the ruff branch October 9, 2023 14:14
un33k added a commit that referenced this pull request Oct 9, 2023
un33k added a commit that referenced this pull request Oct 9, 2023
@un33k
Copy link
Copy Markdown
Owner

un33k commented Oct 9, 2023

@jdevera, I merged this in, but CI wasn't happy with it, and I didn't have time to investigate. I've reverted it for now.

I believe adding feat/* and bug/* to the GitHub action would be beneficial. This way, any push to such a branch would trigger CI, allowing us to know if CI fails before any PR is created.

Had these changes been in feat/flake-ruff, a GitHub action would have been triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants