Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-opus-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Schrödinger's comment: it is both commented-out code and a comment…

  1. 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: ERA001
    
    

    Found commented-out code (ERA001) [Ln 1, Col 4] Unused noqa directive (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"
    

    Playground

    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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /ruff, current file: none) bash-$

  2. Claude Assistant

    Now let me add a helper in noqa.rs.

  3. Claude Assistant

    Now update the ERA001 rule.

  4. Claude Assistant

    Now add the import.

  5. Claude Assistant

    Now update the imports in detection.rs.

  6. Claude Assistant

    Now let's build and test.

  7. Claude Assistant

    All checks are done. Here's my review of the checklist:

    1. Reproduced the reported error: Yes. I created /tmp/era.py containing the exact snippet from the issue (tab-indented # \t) followed by # \t) # noqa: ERA001) and ran ruff check --select ERA,RUF100. Before the fix, ruff emitted ERA001 for the first line and RUF100 Unused noqa directive (unused: ERA001) for the second — exactly the "Schrödinger's comment" behavior described.

    2. Confirmed the fix resolves the error: Yes. After the change, only the ERA001 for line 4 is reported; line 5 is now recognized as commented-out code and is properly suppressed by its # noqa: ERA001, so no RUF100 is emitted. I also verified with git stash/stash pop that the difference is caused by my change.

    3. Edge cases: The root cause was that a trailing noqa directive changed whether the comment text parsed/matched the "positive case" regexes (e.g. ) # noqa: ERA001 no longer matches the brackets-only pattern). I fixed it in comment_contains_code by retrying the detection with a well-formed inline noqa directive stripped (located with ruff's own noqa lexer, reused via a new inline_noqa_directive_range helper in noqa.rs). Using a retry (OR) rather than always stripping means detection is a strict superset of prior behavior, so no new false negatives. I tested: bare # noqa / # noqa: ERA001 lines (still not code), # ) # noqa, # x = foo( # noqa: ERA001 (now detected, consistent with the version without noqa), # print("# noqa") (a # inside a string — the noqa lexer rejects it, so it's still detected as code, no regression), task-tag and pragma comments with a trailing noqa (still not code), and non-ASCII comments (no panic from byte-offset slicing since offsets come from the char-based lexer).

    4. Ran existing tests: Yes. cargo test -p ruff_linter passes fully (2775 tests, including all eradicate unit tests, the ERA001.py fixture snapshot, and all noqa/RUF100 tests), cargo test -p ruff --test cli passes (195 tests), and cargo clippy --all-targets / cargo fmt --check are clean. The single failure ruff::commands::check::test::unreadable_files is pre-existing (reproduced on a clean stash; it fails because the test runs as root), and I removed the stray .snap.new file it generated. I did not add or modify any tests.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.