Match noqa shebang handling in ruff:ignore comments - #26286
Merged
Conversation
Summary -- This addresses another discrepancy Codex noticed between `noqa` and `ruff:ignore` while reviewing my `--add-ignore` PR. `noqa` had special handling for shebang lines, which allowed it to suppress a diagnostic with a 0..0 range, like `D100`, even when a shebang was present that prevented putting the suppression on the first line: ```py #!/usr/bin/python # noqa: D100 ``` [Playground](https://play.ruff.rs/5381b897-06d1-4d41-900b-cc85a40b2740) This was previously not the case for `ruff:ignore`. ```py #!/usr/bin/python # ruff:ignore[D100] ``` [Playground](https://play.ruff.rs/1d3dde25-2692-43f3-a6fb-54b2e156ba66) Test Plan -- A new mdtest covering this scenario
|
in the same section, this gets appended to the other code block and is no longer a shebang. in a separate section, mdtest doesn't extract the trailing `# error` comment on the shebang line, so it's impossible to assert that the error occurs
ntBre
marked this pull request as ready for review
June 23, 2026 22:43
MichaReiser
approved these changes
Jun 24, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This addresses another discrepancy Codex noticed between
noqaandruff:ignorewhile reviewing my--add-ignorePR.noqahad special handling for shebang lines, which allowed it to suppress adiagnostic with a 0..0 range, like
D100, even when a shebang was present that prevented puttingthe suppression on the first line:
Playground
This was previously not the case for
ruff:ignore.Playground
Test Plan
A new mdtest covering this scenario