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
Investigating the ERA001/RUF100 conflict: I'll trace how each rule classifies these comments and why they disagree.
- Assistant
Line 2’s
# noqasuffix is likely why ERA001 skips it while still firing on line 1 — I’ll trace how comment text is parsed before the rule runs. - Assistant
The
# noqasuffix is breaking ERA001 detection on line 2 while line 1 still matches — I'll strip trailing pragmas before analysis, same as E501. - Assistant
The
schrodinger()test function needs a body — I'll add that now. - Assistant
This was a real inconsistency between ERA001 and RUF100. The root cause and fix:
Root cause
ERA001 decides whether a line is commented-out code by analyzing the full comment text. For:
python# ) # noqa: ERA001the analyzed content was
) # noqa: ERA001, which:- does not match the brackets-only heuristic (
^[()\[\]{}\s]+$) - does not parse as valid Python
So ERA001 skipped line 2, while line 1 (
# )) still matched — hence the paradox: thenoqalooked unused even though the lines are effectively the same.Fix
- does not match the brackets-only heuristic (
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.