-
Notifications
You must be signed in to change notification settings - Fork 94
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
Add more pre-commit checks (mccabe, bandit, mypy, etc) #557
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #557 +/- ##
==========================================
- Coverage 94.13% 94.08% -0.06%
==========================================
Files 84 84
Lines 13188 13228 +40
==========================================
+ Hits 12415 12446 +31
- Misses 773 782 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…finition It uses self.get_proj_coords which is an area-only method
Only a tiny bit
@mraspaud @pnuu I think this is ready. Let me know what you think. I took all of the pre-commit configuration from pre-ruff satpy. The biggest issue/difficulty was mccabe complaining about code complexity which isn't surprising given the age of this package. The biggest "offenders" were the new-ish The biggest problem was the
|
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 a lot from breaking down all the complexity! I could not check that the logic was preserved in most places, but trust this is mostly refactoring, right?
And how about using ruff in place of flake8, and maybe even bandit?
@@ -111,7 +112,7 @@ | |||
|
|||
# List of directories, relative to source directory, that shouldn't be searched | |||
# for source files. | |||
exclude_trees = [] | |||
exclude_trees: list[str] = [] |
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.
Does mypy really need to run on this file?
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.
No, but I also don't mind it. I noticed in a new project that sphinx now removes all unnecessary/optional arguments from conf.py
when you run the quickstart command. We could consider comparing that to what is in this conf.py and clearing unused things out.
Here's the ruff config that would mimic what we have with flake8 today:
for bandit, that would be "S", but not I'm unsure the functionality is actually the same. |
Right. There are only two places that I can think of where things were more heavily changed:
|
I had decided not to use it because I did not want to go down the path of all of the rules that I know you worked on for Satpy. The example config you have looks easy enough so I'll try updating to that today. However, ruff still doesn't handle blank lines between functions/methods and it is pretty annoying to me (it has been annoying to me to review Satpy PRs where there are 3 or more lines between functions). What do you think about waiting until that is handled to switch to ruff?
How so? |
oh, ok, I had missed that. That's pretty annoying indeed. We could also have ruff run in parallel with (bare) flake8 then maybe. But otherwise we can wait, yes.
The "S" rule for ruff is an implementation of flake8-bandit, not bandit itself. And flake8-bandit is calling bandit, so I suppose we'd better call bandit directly. |
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.
Looks good, just a couple of comments inline
# Conflicts: # pyresample/geometry.py
Ok so CodeFactor is complaining about 11 things which were all existing TODOs in these modules. Codebeat on the other hand says 0 introduced issues and 125 resolved. Not bad. |
Merging this now and then I'll hope to resolve conflicts in @ghiggi's PR tonight. |
Let's bring pyresample into the modern age of 5 years ago with some real complexity and type checking.
git diff origin/main **/*py | flake8 --diff