Replace Flake8 checks with Ruff (except for flake8-pyi)#11496
Merged
AlexWaygood merged 29 commits intopython:mainfrom Mar 10, 2024
Merged
Replace Flake8 checks with Ruff (except for flake8-pyi)#11496AlexWaygood merged 29 commits intopython:mainfrom
AlexWaygood merged 29 commits intopython:mainfrom
Conversation
This was referenced Feb 29, 2024
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Avasam
commented
Feb 29, 2024
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.
Akuli
reviewed
Feb 29, 2024
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
NQA is already marked as external. I opened astral-sh/ruff#10202 |
Collaborator
Author
|
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.
Avasam
commented
Mar 3, 2024
AlexWaygood
reviewed
Mar 3, 2024
Member
AlexWaygood
left a comment
There was a problem hiding this comment.
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.
Avasam
commented
Mar 4, 2024
This comment has been minimized.
This comment has been minimized.
Member
|
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! |
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
UPandRUFrules.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.