Skip to content

[ruff] Fix ISC003 autofix incorrectly stripping + from comments#26554

Merged
MichaReiser merged 2 commits into
astral-sh:mainfrom
servusdei2018:bracyn/ignore-comments-in-isc003
Jul 6, 2026
Merged

[ruff] Fix ISC003 autofix incorrectly stripping + from comments#26554
MichaReiser merged 2 commits into
astral-sh:mainfrom
servusdei2018:bracyn/ignore-comments-in-isc003

Conversation

@servusdei2018

Copy link
Copy Markdown
Contributor

Closes #26541

Summary

Fixes a bug in the ISC003 (explicit-string-concatenation) autofix where + characters inside inline comments (e.g. # Complains about this: +) were incorrectly stripped instead of the actual + binary operator.

Test Plan

  • Added test cases containing + within inline comments to the ISC.py test fixture.
  • Ran cargo test -p ruff_linter -- flake8_implicit_str_concat to update the snapshots and verify correctness.

@astral-sh-bot
astral-sh-bot Bot requested a review from ntBre July 6, 2026 03:57
@servusdei2018 servusdei2018 changed the title Fix ISC003 autofix incorrectly stripping + from comments [ruff] Fix ISC003 autofix incorrectly stripping + from comments Jul 6, 2026
@MichaReiser MichaReiser added bug Something isn't working fixes Related to suggested fixes for violations labels Jul 6, 2026
@astral-sh-bot

astral-sh-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Comment on lines +131 to +133
// Fallback in case of unexpected token structure
between_operands.split_once('+').unwrap()
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this fallback. It's as likely to panic as if we can't find the token in the token stream.

@MichaReiser

Copy link
Copy Markdown
Member

Thank you

@MichaReiser
MichaReiser merged commit 14a2f67 into astral-sh:main Jul 6, 2026
46 checks passed
@servusdei2018
servusdei2018 deleted the bracyn/ignore-comments-in-isc003 branch July 7, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixes Related to suggested fixes for violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linter 'explicit-string-concatenation' ISC003 includes comment content

2 participants