Skip to content

Make RUF102 also flag file-level noqa codes #23457

@amyreese

Description

@amyreese

It turns out that there are actually two instances of this warning: one for file-level noqa comments and one for line-level comments. RUF102 only covers the line-level case:

ruff check --select RUF102 - <<EOF
# ruff: noqa: X111

1 # noqa: X111
EOF
warning: Invalid rule code provided to `# ruff: noqa` at -:1: X111
warning: Invalid rule code provided to `# noqa` at -:3: X111
RUF102 [*] Invalid rule code in `# noqa`: X111
 --> -:3:3
  |
1 | # ruff: noqa: X111
2 |
3 | 1 # noqa: X111
  |   ^^^^^^^^^^^^
  |
help: Remove the `# noqa` comment

I'll go ahead and remove the warning for the covered case, but I think we should also make RUF102 cover file-level suppression comments and then remove that warning as well. We'll probably need to make that a preview change since the rule has already been stabilized.

Originally posted by @ntBre in #23267

Metadata

Metadata

Assignees

Labels

suppressionRelated to supression of violations e.g. noqa

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions