Files
ruff/python
Brent WestbrookandMicha Reiser a907a12075 [ruff] Add rule to replace noqa comments with ruff:ignore (RUF105) (#26423)
Summary
--

This is the first in a series of migration rules to help users move from
`noqa` comments with rule
codes to `ruff:ignore` comments with names. This rule simply replaces
`noqa: codes` with
`ruff:ignore[codes]` (and the file-level variants), deferring the
transformation of codes to names
to a follow-up rule. This rule may be useful on its own without the
codes -> names rule, assuming we
stabilize `ruff:ignore` in the next minor release without stabilizing
human-readable names.

The rule skips any comment consisting entirely of known `external`
selectors, while still emitting diagnostics for totally unknown codes.
We also skip file-level `flake8: noqa` directives assuming they are
intended to be shared with flake8.

I initially wrote a small, standalone implementation in the rule file
itself, but it had to be
combined with the `RUF100` implementation to leave unused `noqa` codes
out of `RUF105` to be cleaned
up by `RUF100` instead, as I note in the mdtest for this case.

Test Plan
--

New mdtests

I also expect a huge number of ecosystem results on this PR, possibly so
many that the check times out.

---------

Co-authored-by: Micha Reiser <micha@reiser.io>
2026-07-09 16:45:20 -04:00
..