-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[pygrep_hooks
] Check blanket ignores via file-level pragmas (PGH004
)
#11540
Merged
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
654ebf7
Check file-level pragmas for PGH004
ajesipow 3f22083
Remove unnecessary line change
ajesipow 4c3dc41
Remove unnecessary line change
ajesipow 0f7ff38
Extra behaviour only when preview enabled
ajesipow 7ca4429
Add separate preview test for conformity with rest of the codebase
ajesipow 600aed1
Adapt test files for multiple file-level blanket NoQAs
ajesipow d5a668c
Add BlanketNoqaDirectives to extract file level exemptions on multipl…
ajesipow 8574036
Merge branch 'main' into pgh004-file-level
charliermarsh f599caa
Add newline
charliermarsh 24037e4
Tweak message
charliermarsh 4e80490
Add to docs
charliermarsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH004_2.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# ruff: noqa |
1 change: 1 addition & 0 deletions
1
crates/ruff_linter/resources/test/fixtures/pygrep_hooks/PGH004_3.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# flake8: noqa |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
4 changes: 4 additions & 0 deletions
4
...s/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_2.py.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs | ||
--- | ||
|
4 changes: 4 additions & 0 deletions
4
...s/pygrep_hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__PGH004_PGH004_3.py.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs | ||
--- | ||
|
8 changes: 8 additions & 0 deletions
8
...hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__preview__PGH004_PGH004_2.py.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs | ||
--- | ||
PGH004_2.py:1:1: PGH004 Use specific rule codes when using `noqa` | ||
| | ||
1 | # ruff: noqa | ||
| ^^^^^^^^^^^^ PGH004 | ||
| |
8 changes: 8 additions & 0 deletions
8
...hooks/snapshots/ruff_linter__rules__pygrep_hooks__tests__preview__PGH004_PGH004_3.py.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs | ||
--- | ||
PGH004_3.py:1:1: PGH004 Use specific rule codes when using `noqa` | ||
| | ||
1 | # flake8: noqa | ||
| ^^^^^^^^^^^^^^ PGH004 | ||
| |
Oops, something went wrong.
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.
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.
One downside here is that this is only going to flag the first
# ruff: noqa
in the file. I assume if you add multiple such comments, only the first is flagged as a diagnostic?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.
We might need to do something like
NoqaDirectives
, whereby we parse all of these upfront, then use the parsed exemptions incrates/ruff_linter/src/checkers/noqa.rs
(and here).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.
@ajesipow - Do you want to give that a try?
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 for the ping @charliermarsh.
I haven't found the time yet after work this week, but today is a public holiday over here so I'll look into it today :)
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.
I just pushed the changes and adapted the tests again accordingly.
Looking forward to your feedback again.