ruff
b78e92bf - Respect diagnostic start and parent ranges and trailing comments in `ruff:ignore` suppressions (#25673)

Commit
131 days ago
Respect diagnostic start and parent ranges and trailing comments in `ruff:ignore` suppressions (#25673) Summary -- Fixes #25644 by addressing the following cases: ```py suppressed = [ # noqa: RUF015 *range(10) ][0] not_suppressed = [ # ruff:ignore[RUF015] *range(10) ][0] ``` `ruff:ignore` now properly suppresses `RUF015`, even though only the start of the diagnostic occurs within the suppression range. This is the case from #25644. ```py from foo import ( # noqa: F401 bar ) from foo import ( # ruff:ignore[F401] baz ) ``` `ruff:ignore` now properly respects the `parent` range of a diagnostic and suppresses the unused import here, like `noqa`. ```py # ruff:ignore[E262] x = 1 #bad ``` `ruff:ignore` now properly suppresses `E262` here by extending its suppression range to include the full following line rather than skipping over the trailing comment. This case isn't directly related to `noqa` on its own, but it was another separate issue and pointed to a better solution to the other cases. [Playground](https://play.ruff.rs/b877bf42-6fda-4e6a-9d6f-ac3e9e7a1934) Test Plan -- New mdtests based on the cases above
Author
Parents
Loading