Skip to content

Suppress RUF027 fix for f-strings with comments targeting Python < 3.12#23522

Closed
FrederickStempfle wants to merge 1 commit intoastral-sh:mainfrom
FrederickStempfle:fix/ruf027-comment-py311
Closed

Suppress RUF027 fix for f-strings with comments targeting Python < 3.12#23522
FrederickStempfle wants to merge 1 commit intoastral-sh:mainfrom
FrederickStempfle:fix/ruf027-comment-py311

Conversation

@FrederickStempfle
Copy link

Summary

  • Suppresses the RUF027 autofix when the resulting f-string would contain comments inside interpolations, which is invalid syntax before Python 3.12 (PEP 701)
  • Extends the existing backslash check to also cover # in interpolation text
  • Also fixes a latent case in the existing test fixture (triple-quoted string with # comment inside braces)

Test plan

Closes #23460

@ntBre
Copy link
Contributor

ntBre commented Feb 23, 2026

Thanks for working on this, but it looks like there's another PR for this issue from yesterday: #23480. I'll close this for now and plan to review that one first.

@ntBre ntBre closed this Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RUF027 creates invalid f-string interpolations with comments before Python 3.12

2 participants