Schrödinger's comment: it is both commented-out code and a comment that is not code…
- User
Schrödinger's comment: it is both commented-out code and a comment that is not code (ERA001 vs RUF100)
Summary
First, I'm impressed by the recent reduction of ERA001 false positives. I suspect that ERA001 is an exceptionally difficult rule to implement.
This is the only time I've seen this situation.
python# ) # ) # noqa: ERA001Found commented-out code (ERA001) [Ln 1, Col 4] Unused
noqadirective (unused:ERA001) (RUF100) [Ln 2, Col 10]tomlpreview = false builtins = [] target-version = "py310" line-length = 88 indent-width = 4 [lint] allowed-confusables = [] dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" extend-select = [] extend-fixable = [] external = [] ignore = [] select = [ "F", "E4", "E7", "E9", "ERA", "RUF" ] [format] indent-style = "space" quote-style = "double"Version
ruff 0.15.14 (9ad2da301 2026-05-21)
Interface
No new interfaces are introduced.
- Assistant
Now let me check how RUF100 test fixtures are set up, since the user-visible symptom is a RUF100 false positive:
- Assistant
RUF100_5.py already tests RUF100 + ERA001 together:
- Assistant
Now let me reproduce the issue first:
- Assistant
Reproduced. Now let's see where
commented_out_codeis called from, to check whether parsed noqa directives are already available there: - Assistant
No
ghavailable; I'll describe the case in the fixture without an issue link. Now implementing. First, the noqa.rs helper: - Assistant
Now the helper next to
lex_inline_noqa: - Assistant
Now update the ERA001 rule:
- Assistant
Module is private but crate-internal access works with
pub(crate). Now update the fixtures: - Assistant
uvx/uvaren't available in this environment, so I'll run the key formatting check directly: - Assistant
Formatting applied. Final check that everything still passes:
- Assistant
Fixed. The Schrödinger's comment paradox is resolved: a trailing
# noqano longer changes whether ERA001 detects the rest of the line as code.Root cause
ERA001 fed the entire line — including any trailing
# noqa: ...suffix — into its code-detection heuristics incomment_contains_code. For# ), the bracket-only regex^[()\[\]{}\s]+$matches, so ERA001 fires. But for# ) # noqa: ERA001, the noqa text defeats that regex (and the line doesn't parse as Python), so ERA001 fire — which made the very noqa the user added to suppress it look unused, triggering RUF100.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.