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 add unit tests next to the existing bracket/assignment cases:
- Assistant
Now add regression cases to the fixture:
- Assistant
uv/prekaren't available in this environment, so I'll run the key equivalent checks directly: - Assistant
Now run the full
ruff_lintertest suite to catch any other affected snapshots (other fixtures might contain bracket-only comments with trailing text): - Assistant
All 2775
ruff_lintertests pass, with only the intended ERA001 snapshot updated. The fix is complete.Summary
Root cause: In
comment_contains_code(crates/ruff_linter/src/rules/eradicate/detection.rs:63), the "Brackets" positive case (^[()\[\]{}\s]+$) matched)but not) # noqa: ERA001— the trailingnoqatext broke the match, and the line doesn't parse as Python either. So ERA001 fired on the bare# )but not on the noqa'd twin, making RUF100 report the directive as unused. Meanwhile the "Partial dictionary" positive case already tolerated a trailing comment via(#.*)?, which is why# "key1": 123, # noqa: ERA001behaved correctly.Fix in
detection.rs:- Brackets:
^[()\[\]{}\s]+$→^[()\[\]{}\s]+(#.*)?$ - Multiline assignment (same latent bug, e.g. ): appended before
- Brackets:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.