-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace flake8 with ruff in pre-commit and ci linting #2586
Conversation
What triggers this change? Is it necessary to switch over for some reason, or is |
Ruff has much better performance. Since we run linting on every commit (when pre-commit is installed), I thought it would be nice to save computing time for everyone, and for the linting ci. Another good thing is that is supports pyproject.toml which flake8 does not do. See a list of benefits on the top of this page https://docs.astral.sh/ruff/ |
I am OK with adopting ruff, but I think we could drop the lint/style checks in the CI in favor of pre-commit.ci doing it all. Also...adopt black? |
Ok, I can do that
Black is not a linter, this is about linting 😁 |
Rely on pre-commit entirely now.
Sure, a separate PR. But it would be run in pre-commit so it isn't way out of the realm of conversation here and is something that would automatically fix many syntax/style errors complained about here. |
Indeed, I was just trying to avoid the question as I don't like black and I would rather not have it in satpy, which may not be a popular opinion. I would like this PR to be about ruff, but we can make an issue about black to discuss the pros and cons of it if you like. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote for removing the linting job in CI, but otherwise I'm good with whatever rules you want to apply. Can we tell ruff what version(s) of python to target so you don't have to have the B905 rule ignored?
Looks good, but let's merge this after and not before the new release. |
Co-authored-by: Gerrit Holl <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #2586 +/- ##
=======================================
Coverage 95.18% 95.18%
=======================================
Files 354 354
Lines 51253 51256 +3
=======================================
+ Hits 48786 48789 +3
Misses 2467 2467
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Will do! |
@djhoese @gerritholl ok, I think have to stop working on this, because it's way too time consuming for my health atm. I did not add all the rules I planned to, but the ones we have currently in main are implemented, and even a couple new ones. If you want to review this, I highly recommend you check the changes by commit, since they should be consistent with one new rule per commit. Especially the one for pytest-style, which is a mouthful. |
I was honestly surprised when you said you were starting this. This is the same reason I didn't do it earlier. |
There are a lot of test failures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting all the work into this. There are test failures, but otherwise this looks good to me. Let's see if we can track down these failures.
This PR uses ruff instead of flake8 and mccabe.
It also add news rules for linting, so I'm expecting this to fail and start a discussion about what rules to use.
When that is done, I will fix satpy accordingly.
As first draft, here what I propose:
port of previously used flake8 and plugins used in satpy
new checks
I'm also open to adding more checks, the full list is here:
https://docs.astral.sh/ruff/rules/