mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 21:04:29 +08:00
f-string syntax in Python 3.8 was enhanced
See e.g. https://twitter.com/raymondh/status/1135253771846471680
This commit is contained in:
@@ -153,5 +153,5 @@ strings: (STRING | fstring)+
|
|||||||
fstring: FSTRING_START fstring_content* FSTRING_END
|
fstring: FSTRING_START fstring_content* FSTRING_END
|
||||||
fstring_content: FSTRING_STRING | fstring_expr
|
fstring_content: FSTRING_STRING | fstring_expr
|
||||||
fstring_conversion: '!' NAME
|
fstring_conversion: '!' NAME
|
||||||
fstring_expr: '{' testlist [ fstring_conversion ] [ fstring_format_spec ] '}'
|
fstring_expr: '{' testlist ['='] [ fstring_conversion ] [ fstring_format_spec ] '}'
|
||||||
fstring_format_spec: ':' fstring_content*
|
fstring_format_spec: ':' fstring_content*
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ FAILING_EXAMPLES = [
|
|||||||
# Now nested parsing
|
# Now nested parsing
|
||||||
"f'{continue}'",
|
"f'{continue}'",
|
||||||
"f'{1;1}'",
|
"f'{1;1}'",
|
||||||
"f'{a=3}'",
|
"f'{a*=3}'",
|
||||||
"f'{b\"\" \"\"}'",
|
"f'{b\"\" \"\"}'",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from parso.python.tokenize import tokenize
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def grammar():
|
def grammar():
|
||||||
return load_grammar(version='3.6')
|
return load_grammar(version='3.8')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@@ -31,6 +31,10 @@ def grammar():
|
|||||||
'{{{1}',
|
'{{{1}',
|
||||||
'1{{2{{3',
|
'1{{2{{3',
|
||||||
'}}',
|
'}}',
|
||||||
|
|
||||||
|
# New Python 3.8 syntax f'{a=}'
|
||||||
|
'{a=}',
|
||||||
|
'{a()=}',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_valid(code, grammar):
|
def test_valid(code, grammar):
|
||||||
|
|||||||
Reference in New Issue
Block a user