Skip to content
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

Merged
merged 2 commits into from
Feb 18, 2025

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Feb 11, 2025

Move flake8 linter settings from the file .flake8 into pyproject.toml by using Flake8-pyproject.

% uv run --with=Flake8-pyproject flake8 isort/ tests/

Fixes: #2356

Related to:

Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.16%. Comparing base (7190d1d) to head (7de0a2d).
Report is 3 commits behind head on main.

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           

@cclauss cclauss changed the title uv run --with=Flake8-pyproject flake8 isort/ tests/ Move flake8 settings into pyproject.toml Feb 11, 2025
@DanielNoord
Copy link
Member

I think @staticdev pointed in #2356 (comment) towards just replacing flake8 so that we would also no longer need this.

@cclauss
Copy link
Contributor Author

cclauss commented Feb 12, 2025

@DanielNoord
Copy link
Member

That's just a string in a test case. The test itself might be dependent on flake8 being in the environment but we can 1) fix that and 2) even if we didn't we wouldn't need to config for flake8 anymore.

@cclauss
Copy link
Contributor Author

cclauss commented Feb 12, 2025

  • Remove .flake8 config #2356 is not about removing flake8 so this pull request is merely about moving flake8 config to align with PEP 621.

Several flake8 plugins require stable interactions between flake8 and isort.
https://github.com/orgs/wemake-services/repositories?q=flake8 has three flake8 plugins that rely on isort.profile = wecare and there are other flake8 plugins that depend on sorting imports like:

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
Copy link
Collaborator

@staticdev staticdev Feb 13, 2025

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.

Copy link
Contributor Author

@cclauss cclauss Feb 13, 2025

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

@cclauss cclauss Feb 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@staticdev
Copy link
Collaborator

I think @staticdev pointed in #2356 (comment) towards just replacing flake8 so that we would also no longer need this.

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.

@cclauss cclauss requested a review from staticdev February 14, 2025 09:19
Copy link
Collaborator

@staticdev staticdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cclauss LGTM.

@cclauss
Copy link
Contributor Author

cclauss commented Feb 16, 2025

@staticdev staticdev merged commit c232180 into PyCQA:main Feb 18, 2025
21 checks passed
@cclauss cclauss deleted the flake8-pyproject branch February 18, 2025 21:38
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.

Remove .flake8 config
3 participants