Allow some unparenthesized syntactic structures in f-string expression part (#159)

Resolves #157, #158
This commit is contained in:
Saiyang Gou
2020-11-19 05:32:59 -08:00
committed by GitHub
parent 034a9e8944
commit b08b61b578
7 changed files with 14 additions and 5 deletions

View File

@@ -60,6 +60,13 @@ def grammar():
# a line continuation inside of an format spec
'f"{123:.2\\\nf}"',
# some unparenthesized syntactic structures
'f"{*x,}"',
'f"{*x, *y}"',
'f"{x, *y}"',
'f"{*x, y}"',
'f"{x for x in [1]}"',
]
)
def test_valid(code, grammar):

View File

@@ -274,6 +274,8 @@ def test_paren_kwarg():
r'fr"\""',
r'fr"\\\""',
r"print(f'Some {x:.2f} and some {y}')",
# Unparenthesized yield expression
'def foo(): return f"{yield 1}"',
]
)
def test_valid_fstrings(code):