You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Formatter does not apply nested-string-quote-style alternation inside format-spec interpolations #28218
When the formatter normalizes an f-string's outer quotes to the configured quote-style, nested-string-quote-style = "alternating" (the default) is applied to string literals in normal interpolations, but not to string literals in interpolations inside a format spec.
a: inner quotes alternated to '. b: the interpolation inside the format spec keeps ", reusing the outer quote.
When targeting Python < 3.12 (e.g. requires-python = ">=3.11"), the output is then also a syntax error (PEP 701 quote reuse), rejected by ruff check itself:
invalid-syntax: Cannot reuse outer quote character in f-strings on Python 3.11 (syntax was added in Python 3.12)
changed the title [-]Formatter reuses outer quote in f-string format-spec interpolations, emitting pre-3.12 invalid syntax with target-version py311[/-][+]Formatter does not apply nested-string-quote-style alternation inside format-spec interpolations[/+]on Sep 1, 2026
Activity
[-]Formatter reuses outer quote in f-string format-spec interpolations, emitting pre-3.12 invalid syntax with target-version py311[/-][+]Formatter does not apply nested-string-quote-style alternation inside format-spec interpolations[/+]ntBre commentedon Sep 1, 2026
Thanks for the report! It looks like I introduced this in #20930.
Advance interpolated string nesting at string entry