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)
Interface
No new interfaces are introduced.
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.
Assistant
RUF100 is no longer flagged. Now let's run the existing eradicate tests to ensure nothing broke.
Assistant
All eradicate tests pass. Now let's also run broader related tests (RUF100 / noqa) to be safe, and check snapshot tests didn't change unexpectedly.
Assistant
Good, no accidental append happened. Now let's write a proper temporary test script (rust) to verify additional edge cases without modifying the actual test files.
Assistant
Line 1's noqa correctly suppresses the diagnostic and no RUF100 unused-noqa is raised. This confirms the fix resolves the reported Schrödinger's comment paradox. Now let's run the full eradicate test suite again and check other related snapshot tests (RUF100) to be thorough.
Assistant
All relevant tests pass. Let's also run the broader linter test suite quickly to be safe (full test suite might take long, but let's try a limited run of relevant modules).
Assistant
All 2775 tests pass with 0 failures. Let's clean up temp files and view the final diff.
Assistant
The fix is minimal and targeted. Let me review the checklist items now.
Checklist review:
-
I have successfully reproduced the reported error: Yes. I created a script with nested
ifblocks containing# )followed by# ) # noqa: ERA001and confirmed ruff reported bothERA001on the first comment line andRUF100(unused noqa) on the second comment line, exactly matching the issue. -
I have confirmed that my fix resolves the error: Yes. After the fix, both
# )and# ) # noqa: ERA001are correctly recognized as commented-out code (the "Brackets" heuristic incomment_contains_codenow tolerates a trailing inline comment, e.g.# noqa: ..., similar to how the existing "Partial dictionary" heuristic already did). This means thenoqaon the second line now suppresses an actualERA001violation on that same line, soRUF100no longer fires as "unused".
-
Assistant
Confirmed: only 1 error remains (the legitimate one on the un-suppressed line), and
RUF100no longer flags thenoqaas unused.-
I have thought about edge cases and made sure my fix handles them as well: Yes, I tested several edge cases:
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.