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
I'll start by exploring the repository structure and reproducing the ERA001 vs RUF100 conflict described in the issue.
- Assistant
Let me find the ERA001 and RUF100 implementations and try to reproduce the issue.
- Assistant
rg is not found, let me use grep instead.
- Assistant
Let me look at the eradicate commented_out_code rule and how noqa interacts with it.
- Assistant
The second line has a nested noqa inside a comment — I'll inspect detection and noqa handling next.
- Assistant
I'll dig into how noqa directives are parsed and how they interact with ERA001 diagnostics.
- Assistant
Let me look at noqa.rs and the checkers/noqa.rs, and also try to reproduce with the ruff binary if available.
- Assistant
Checking for a prebuilt binary and reviewing recent ERA001-related changes.
- Assistant
Let me look at the recent fix for false positive with leading whitespace - that might be related.
- Assistant
I suspect the fix is stripping noqa before code detection so
# ) # noqa: ERA001still counts as code. Checking how other rules handle that. - Assistant
Looking at the ERA001 fixture and snapshot for how noqa interacts with commented-out code.
- Assistant
I'll inspect how noqa is parsed from full-line comments and whether ERA should strip those directives first.
- Assistant
Confirming: adding
# noqa: ERA001can make a line stop looking like code, so the noqa is unused. Checking for prior discussion and how to strip it. - Assistant
There's a related commit about trailing comments — let me inspect it.
- Assistant
This matches a prior dictionary trailing-comment fix. I'll inspect that test and the brackets positive-case pattern.
- Assistant
Checking whether SimpleTokenizer can strip trailing comments generically.
- Assistant
I'll implement stripping trailing comments so brackets-only lines with
# noqastill count as code, then build and run the tests. - Assistant
Implementing trailing-comment stripping in the detection logic.
- Assistant
Adding unit tests for the issue case, then running the detection tests.
- Assistant
Let me add a test for trailing noqa on brackets after the multiline test.
- Assistant
There's an extra brace to remove.
- Assistant
Duplicate #[test] - need to fix.
- Assistant
Removing the unit test additions per the instruction not to add or change tests.
- Assistant
There's still an extra brace to remove.
- Assistant
There's still a duplicate #[test]. Let me fix that.
- Assistant
Verifying the SimpleToken API for kind checks.
- Assistant
Building and running the eradicate tests to verify the fix.
- Assistant
Need to import Ranged or use
.range.start(). - Assistant
Let me rebuild and test.
- Assistant
All eradicate tests passed. Next I'll exercise the RUF100 interaction and reproduce the original issue with a temporary script.
- Assistant
Reproducing the original issue with a temporary file.
- Assistant
The fix works. Tightening the comment to match codebase style.
- Assistant
Restoring a blank line that was dropped.
- Assistant
Rebuilding and re-checking the original issue and a few edge cases.
- Assistant
Verifying the final diff and cleaning up temp files.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.