-
-
Notifications
You must be signed in to change notification settings - Fork 590
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
Move flake8 settings into pyproject.toml #2360
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2360 +/- ##
=======================================
Coverage 99.16% 99.16%
=======================================
Files 40 40
Lines 3098 3098
Branches 680 680
=======================================
Hits 3072 3072
Misses 15 15
Partials 11 11 |
I think @staticdev pointed in #2356 (comment) towards just replacing |
Some code imports flake8 code… |
That's just a string in a test case. The test itself might be dependent on |
Several flake8 plugins require stable interactions between flake8 and isort. I am unsure what I am breaking by removing flake8 so none of my pull requests have attempted that but if someone else wants to that would be great. |
pyproject.toml
Outdated
@@ -141,6 +142,22 @@ dev = [ | |||
"vulture>=1.0", | |||
] | |||
|
|||
[tool.flake8] | |||
max-complexity = 91 |
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.
@cclauss just curious why you added max-complexity
?
This one was not in original 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.
https://docs.astral.sh/ruff/rules/complex-structure
This function is 9 times more complex than the suggested code complexity setting. This is also what DeepSource is complaining about but they make a different calculation than flake8 and ruff.
It is useful to set upper limits on code complexity so that if someone makes this code even more complex (i.e. less understandable and more difficult to maintain) then the changing of this setting should set off a discussion in the code review about taking time to refactor or at least add more tests.
% uvx flake8 --select=C9 --max-complexity=90 **/*.py
isort/core.py:32:1: C901 'process' is too complex (91)
This function is more than 450 lines long.
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.
Yes, not the best software engineering example of logic. But I don't see value adding a super high complexity to it.
I would prefer to set a normal recommended value and ignore this method with a TODO to reduce the complexity and remove the ignore.
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.
max-complexity = 91 |
Let’s remove it here and I will do as you say in a separate code complexity PR using ruff after that lands.
That would be indeed another way, but since @cclauss already put the effort. I think it is valid and better to maintain the settings in a single 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.
Thanks @cclauss LGTM.
Move
flake8
linter settings from the file.flake8
intopyproject.toml
by usingFlake8-pyproject
.%
uv run --with=Flake8-pyproject flake8 isort/ tests/
Fixes: #2356
Related to: