Allow 'any' expression on decorators, PEP 614

This commit is contained in:
Batuhan Taskaya
2020-05-22 02:56:20 +03:00
committed by Dave Halter
parent f8709852e3
commit 345374d040
3 changed files with 16 additions and 1 deletions

View File

@@ -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))

View File

@@ -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)

View File

@@ -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)