Fix joining of f-strings with different quotes when using quote style Preserve (#15524)

This commit is contained in:
Micha Reiser 2025-01-16 12:01:42 +01:00 committed by GitHub
parent fc9dd63d64
commit 420365811f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 55 additions and 11 deletions

View file

@ -11,3 +11,12 @@ a = "different '" 'quote "are fine"' # join
# Already invalid Pre Python 312
f"{'Hy "User"'}" f'{"Hy 'User'"}'
# Regression tests for https://github.com/astral-sh/ruff/issues/15514
params = {}
string = "this is my string with " f'"{params.get("mine")}"'
string = f'"{params.get("mine")} ' f"with {'nested single quoted string'}"
string = f"{'''inner ' '''}" f'{"""inner " """}'
string = f"{10 + len('bar')=}" f"{10 + len('bar')=}"
string = f"{10 + len('bar')=}" f'{10 + len("bar")=}'