mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-07 05:14:29 +08:00
async is actually a token that cannot appear in brackets
This commit is contained in:
@@ -258,6 +258,8 @@ def _create_token_collection(version_info):
|
|||||||
|
|
||||||
ALWAYS_BREAK_TOKENS = (';', 'import', 'class', 'def', 'try', 'except',
|
ALWAYS_BREAK_TOKENS = (';', 'import', 'class', 'def', 'try', 'except',
|
||||||
'finally', 'while', 'with', 'return')
|
'finally', 'while', 'with', 'return')
|
||||||
|
if version_info >= (3, 5):
|
||||||
|
ALWAYS_BREAK_TOKENS += ('async',)
|
||||||
pseudo_token_compiled = _compile(PseudoToken)
|
pseudo_token_compiled = _compile(PseudoToken)
|
||||||
return TokenCollection(
|
return TokenCollection(
|
||||||
pseudo_token_compiled, single_quoted, triple_quoted, endpats,
|
pseudo_token_compiled, single_quoted, triple_quoted, endpats,
|
||||||
|
|||||||
@@ -1487,3 +1487,25 @@ def test_invalid_function(differ):
|
|||||||
''')
|
''')
|
||||||
differ.initialize(code1)
|
differ.initialize(code1)
|
||||||
differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)
|
differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)
|
||||||
|
|
||||||
|
|
||||||
|
def test_async_func2(differ):
|
||||||
|
code1 = dedent('''\
|
||||||
|
async def foo():
|
||||||
|
return ''
|
||||||
|
@bla
|
||||||
|
async def foo():
|
||||||
|
x
|
||||||
|
''')
|
||||||
|
code2 = dedent('''\
|
||||||
|
async def foo():
|
||||||
|
return ''
|
||||||
|
|
||||||
|
{
|
||||||
|
@bla
|
||||||
|
async def foo():
|
||||||
|
x
|
||||||
|
y
|
||||||
|
''')
|
||||||
|
differ.initialize(code1)
|
||||||
|
differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user