ISSUE DESCRIPTION Schrödinger's comment: it is both commented-out code and a comment…
- User
ISSUE DESCRIPTION
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.
# ) # ) # noqa: ERA001Found commented-out code (ERA001) [Ln 1, Col 4] Unused
noqadirective (unused:ERA001) (RUF100) [Ln 2, Col 10]preview = 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)
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- Assistant
I’ll first locate the ERA001 and RUF100 implementations and their tests, then reproduce the interaction with the repository’s test tooling. The likely fix is in how
noqasuppression ranges are associated with diagnostics when adjacent comment lines are grouped, but I’ll verify before editing. - Assistant
ripgrepis unavailable in this environment, so I’ll usegrep/findto locate the rule sources and fixtures. - Assistant
I found the relevant checker and rule. Next I’ll inspect the ERA implementation, the
noqabookkeeping, and existing fixture cases to determine whether the diagnostic range or comment grouping causes the mismatch. - Assistant
The ERA detector classifies
# )as code, but the same text followed by# noqais apparently no longer classified as code. Since Ruff supportsnoqaon the final line of certain multi-line constructs viaNoqaMapping, I’ll inspect both detection normalization and mapping construction, then reproduce using the built binary/test harness. - Assistant
The root cause is now clear: ERA’s explicit “brackets-only” positive case recognizes
# ), but not the equivalent commented-out code with an inline comment (# ) # noqa: ERA001). Python tokenization correctly treats the second#as an inline comment, so the detector should likewise allow it. This makes line 2 produce ERA001 internally, allowing its directive to suppress that diagnostic and count as used; line 1 remains reported. I’ll reproduce current output before changing the regex. - Assistant
The reproduction exactly matches the report. I’ll make the narrow, general fix to the bracket-only positive-case regex: permit an optional Python inline comment after the bracket sequence. This avoids risky global stripping (which could mishandle
#inside strings) while coveringnoqaand ordinary explanatory inline comments. - Assistant
The targeted detector tests pass, and rebuilding Ruff confirms the reported input now emits only the unsuppressed line-1 ERA001; RUF100 is gone. I’ll now run the full eradicate rule test group and probe edge cases: all bracket types with inline comments should be recognized, prose containing brackets should remain ignored, and a same-line
noqashould suppress the newly recognized diagnostic. - Assistant
The full eradicate test group passes (13/13). Edge probing confirms bracket-only code with both spaced and unspaced inline comments is detected, while the
noqa-annotated bracket line is suppressed without RUF100. Prose behavior is unchanged by this regex because text before the inline-comment marker cannot match the bracket-only character class. I’ll clarify the regex comment, rerun formatting/diff validation, and then submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.