-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Replace Flake8 checks with Ruff (except for flake8-pyi) #11496
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
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
NQA is already marked as external. I opened astral-sh/ruff#10202 |
This will conflict with #11522 and some Ruff config changes don't make sense w/o the pre-commit changes, so we can't have this PR work standalone whilst avoiding conflicts. Keeping as draft for now for that reason. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Very nice! One comment suggestion, and one question:
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
LGTM!
If we did want to use diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index dc4bc138b..9612c5417 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -20,12 +20,12 @@ repos:
# Run this separately because we don't really want
# to use --unsafe-fixes for all rules
name: Remove unnecessary `sys.version_info` blocks
- args: ["--exit-non-zero-on-fix", "--select=UP036", "--unsafe-fixes"]
+ args: ["--isolated", "--target-version=py38", "--exit-non-zero-on-fix", "--select=UP036", "--fix", "--unsafe-fixes"]
- id: ruff
# Very few rules are useful to run on our test cases;
# we explicitly enumerate them here:
name: Run ruff on the test cases
- args: ["--exit-non-zero-on-fix", "--select=FA,I", "--no-force-exclude", "--unsafe-fixes"]
+ args: ["--isolated", "--target-version=py38", "--exit-non-zero-on-fix", "--select=FA,I", "--no-force-exclude", "--fix", "--unsafe-fixes"]
files: '.*test_cases/.+\.py$' But I personally find this PR's current solution cleaner! |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
I got curious to see if we could replace the rest of Flake8 (but keeping flake8-pyi and with it flake8-noqa) with Ruff.
I've also been less selective about
UP
andRUF
rules.This is the result.
The bigger challenges and possible roadbump I'd say are astral-sh/ruff#3011 and plinss/flake8-noqa#22 / plinss/flake8-noqa#30
There's a couple things here that can be immediately useful that I'll split up into smaller PRs.