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.
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.
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:
- Assistant
I'll start by exploring the repository structure and reproducing the Schrödinger's comment issue with ERA001 vs RUF100.
- Assistant
Next I'll locate the ERA001 implementation and how noqa interacts with it.
- Assistant
Let me look at the eradicate rule implementation more carefully.
- Assistant
I'll read the ERA001 implementation and related tests next.
- Assistant
I'll inspect how
comment_contains_codedecides whether a line is code. - Assistant
Let me continue reading detection.rs and also try to reproduce the issue.
- Assistant
Hypothesis: trailing
# noqaprevents a line from being detected as code. I'll verify that and check how noqa is stripped elsewhere. - Assistant
I'll inspect noqa parsing and check for existing patterns that strip trailing noqa comments.
- Assistant
I'll check recent eradicate changes and search for related issues or TODOs.
- Assistant
I'll check how
SimpleTokenizerhandles comments and whether we can strip a trailing# noqasafely. - Assistant
Checking whether SimpleTokenizer handles string literals correctly:
- Assistant
SimpleTokenizer doesn't seem to have a String token. Let me check what happens with strings.
- Assistant
Looking at how the parser/lexer can help strip trailing comments robustly.
- Assistant
I'll check the original eradicate behavior and existing GitHub issue patterns.
- Assistant
Let me look at the original eradicate positive cases for brackets.
- Assistant
I'll inspect the lexer API next so we can strip trailing comments correctly.
- Assistant
Let me look at TokenKind and Lexer interface.
- Assistant
Let me look at TokenKind for Comment and how to iterate backticks.
- Assistant
Hmm where is TokenKind defined?
- Assistant
I'll check whether TokenKind and the lexer are usable from ruff_linter.
- Assistant
Let me check if lex and current_range are public enough.
- Assistant
I'll read the rest of the tests and implement the regex fix.
- Assistant
Implementing a trailing-comment strip so
# ) # noqa: ERA001is still treated as code. - Assistant
I'll add unit tests covering the Schrödinger case and similar edge cases.
- Assistant
I need to restore the broken test function structure.
- Assistant
I'll verify the SimpleToken API and fix any issues.
- Assistant
I'll add a fixture case and run the eradicate tests.
- Assistant
There's an extra closing brace — I'll inspect and fix it.
- Assistant
Removing the extra brace.
- Assistant
There's a duplicate
#[cfg(test)]. Let me fix that. - Assistant
Rerunning the tests now.
- Assistant
I need to import the
Rangedtrait. - Assistant
Lost a blank line after use statements but that's fine. Let me rerun tests.
- Assistant
Detection works; trailing
noqasuppresses ERA001. Updating the snapshot and verifying RUF100 end-to-end. - Assistant
Reproducing the original issue with the built binary.
- Assistant
Confirming the fix and running related tests.
- Assistant
I'll check RUF100 fixtures for ERA interaction cases.
- Assistant
The checklist says not to modify or add tests — reverting fixture, snapshot, and unit-test changes and keeping only the fix.
- Assistant
Removing the unit test additions.
- Assistant
Cleaning up the duplicated test function header.
- Assistant
I'll restore the tests section from git and keep only the implementation changes.
- Assistant
Verifying the file and re-running tests.
- Assistant
Simplifying the unused variable and doing a final verification.
- Assistant
Need to navigate to the right line for replace when using the open file.
- Assistant
Let me simplify with edit.
- Assistant
I'll rebuild ruff and verify with the original case and edge cases.
- Assistant
Running a comprehensive temporary verification.
- Assistant
I had typos in the shell script. Let me fix and rerun.
- Assistant
RUF100 tests still look good — I'll run those next.
- Assistant
All set — final review of the change, 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.