Schrödinger's comment: it is both commented-out code and a comment that is not code…
- User
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.
- Assistant
Investigating how ERA001 and RUF100 interact for this edge case.
- Assistant
Stripping trailing
# noqabefore ERA001 detection so noqa doesn't change whether a line is classified as code. - Assistant
Avoiding unnecessary allocation with
Cow: - Assistant
The fix works. Removing the unused import and checking the snapshot.
- Assistant
This was a real inconsistency between ERA001 and RUF100.
Root cause:
comment_contains_codeanalyzed the full comment text, including any trailing# noqa. For# ), the stripped content)matches the bracket-only heuristic and triggers ERA001. For# ) # noqa: ERA001, the content) # noqa: ERA001no longer matches, so ERA001 does not fire — but RUF100 still sees an unusednoqa: ERA001.Fix: Strip trailing inline
# noqadirectives before ERA001 classifies the comment. Both lines are now treated the same for detection; thenoqaon line 2 correctly suppresses ERA001 there, and RUF100 no longer reports it as unused.pub(crate) fn comment_contains_code(line: &str, task_tags: &[String]) -> bool { let line = { let stripped = line .trim_start_matches(|char| char == '#' || is_python_whitespace(char)) .trim_end(); TRAILING_INLINE_NOQA.replace(stripped, "") }; let line = line.trim_end(); // ...After the fix, your example reports only one diagnostic — ERA001 on line 1 (which has no ). Line 2 is cleanly suppressed.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.