mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:39:12 +00:00
Fix unstable f-string formatting for expressions containing a trailing comma (#15545)
This commit is contained in:
parent
fdb9f4e404
commit
1ecb7ce645
4 changed files with 45 additions and 0 deletions
|
@ -725,6 +725,7 @@ print(f"{({1, 2, 3}) - ({2})}")
|
|||
print(f"{1, 2, {3} }")
|
||||
print(f"{(1, 2, {3})}")
|
||||
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/15535
|
||||
print(f"{ {}, }") # A single item tuple gets parenthesized
|
||||
print(f"{ {}.values(), }")
|
||||
|
@ -732,6 +733,10 @@ print(f"{ {}, 1 }") # A tuple with multiple elements doesn't get parenthesized
|
|||
print(f"{ # Tuple with multiple elements that doesn't fit on a single line gets parenthesized
|
||||
{}, 1,
|
||||
}")
|
||||
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/15536
|
||||
print(f"{ {}, 1, }")
|
||||
```
|
||||
|
||||
## Outputs
|
||||
|
@ -1515,6 +1520,7 @@ print(f"{({1, 2, 3}) - ({2})}")
|
|||
print(f"{1, 2, {3}}")
|
||||
print(f"{(1, 2, {3})}")
|
||||
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/15535
|
||||
print(f"{({},)}") # A single item tuple gets parenthesized
|
||||
print(f"{({}.values(),)}")
|
||||
|
@ -1527,6 +1533,10 @@ print(
|
|||
)
|
||||
}"
|
||||
)
|
||||
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/15536
|
||||
print(f"{ {}, 1 }")
|
||||
```
|
||||
|
||||
|
||||
|
@ -2310,6 +2320,7 @@ print(f"{({1, 2, 3}) - ({2})}")
|
|||
print(f"{1, 2, {3}}")
|
||||
print(f"{(1, 2, {3})}")
|
||||
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/15535
|
||||
print(f"{({},)}") # A single item tuple gets parenthesized
|
||||
print(f"{({}.values(),)}")
|
||||
|
@ -2322,4 +2333,8 @@ print(
|
|||
)
|
||||
}"
|
||||
)
|
||||
|
||||
|
||||
# Regression tests for https://github.com/astral-sh/ruff/issues/15536
|
||||
print(f"{ {}, 1 }")
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue