mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-16 01:17:13 +08:00
Allow 'any' expression on decorators, PEP 614
This commit is contained in:
committed by
Dave Halter
parent
f8709852e3
commit
345374d040
@@ -163,3 +163,8 @@ def works_ge_py35(each_version):
|
|||||||
def works_ge_py38(each_version):
|
def works_ge_py38(each_version):
|
||||||
version_info = parse_version_string(each_version)
|
version_info = parse_version_string(each_version)
|
||||||
return Checker(each_version, version_info >= (3, 8))
|
return Checker(each_version, version_info >= (3, 8))
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def works_ge_py39(each_version):
|
||||||
|
version_info = parse_version_string(each_version)
|
||||||
|
return Checker(each_version, version_info >= (3, 9))
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE
|
|||||||
file_input: stmt* ENDMARKER
|
file_input: stmt* ENDMARKER
|
||||||
eval_input: testlist NEWLINE* ENDMARKER
|
eval_input: testlist NEWLINE* ENDMARKER
|
||||||
|
|
||||||
decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
|
decorator: '@' namedexpr_test NEWLINE
|
||||||
decorators: decorator+
|
decorators: decorator+
|
||||||
decorated: decorators (classdef | funcdef | async_funcdef)
|
decorated: decorators (classdef | funcdef | async_funcdef)
|
||||||
|
|
||||||
|
|||||||
@@ -208,3 +208,13 @@ def test_named_expression(works_ge_py38):
|
|||||||
)
|
)
|
||||||
def test_positional_only_arguments(works_ge_py38, param_code):
|
def test_positional_only_arguments(works_ge_py38, param_code):
|
||||||
works_ge_py38.parse("def x(%s): pass" % param_code)
|
works_ge_py38.parse("def x(%s): pass" % param_code)
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'expression', [
|
||||||
|
'a + a',
|
||||||
|
'lambda x: x',
|
||||||
|
'a := lambda x: x'
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_decorator_expression(works_ge_py39, expression):
|
||||||
|
works_ge_py39.parse("@%s\ndef x(): pass" % expression)
|
||||||
|
|||||||
Reference in New Issue
Block a user