Skip to content

Commit

Permalink
Respect per-file-ignores for RUF100 on blanket # noqa (#10908)
Browse files Browse the repository at this point in the history
## Summary

If `RUF100` was included in a per-file-ignore, we respected it on cases
like `# noqa: F401`, but not the blanket variant (`# noqa`).

Closes #10906.
  • Loading branch information
charliermarsh authored Apr 12, 2024
1 parent 2e37cf6 commit a013050
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import os
import foo # noqa: F401
import bar # noqa
3 changes: 2 additions & 1 deletion crates/ruff_linter/src/checkers/noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pub(crate) fn check_noqa(
FileExemption::All => true,
FileExemption::Codes(codes) => codes.contains(&Rule::UnusedNOQA.noqa_code()),
})
&& !per_file_ignores.contains(Rule::UnusedNOQA)
{
for line in noqa_directives.lines() {
match &line.directive {
Expand All @@ -129,7 +130,7 @@ pub(crate) fn check_noqa(
let mut unknown_codes = vec![];
let mut unmatched_codes = vec![];
let mut valid_codes = vec![];
let mut self_ignore = per_file_ignores.contains(Rule::UnusedNOQA);
let mut self_ignore = false;
for code in directive.codes() {
let code = get_redirect_target(code).unwrap_or(code);
if Rule::UnusedNOQA.noqa_code() == code {
Expand Down

0 comments on commit a013050

Please sign in to comment.