Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion parso/python/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ def is_issue(self, leaf):

@ErrorFinder.register_rule(value='*')
class _StarCheck(SyntaxRule):
message = "named arguments must follow bare *"
if sys.version_info[:2] < (3, 15):
message = "named arguments must follow bare *"
else:
message = "named parameters must follow bare *"

def is_issue(self, leaf):
params = leaf.parent
Expand Down
9 changes: 7 additions & 2 deletions test/failing_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def build_nested(code, depth, base='def f():\n'):
'del *a, b',
'def x(*): pass',
'(%s *d) = x' % ('a,' * 256),
'{**{} for a in [1]}',
'(True,) = x',
'([False], a) = x',
'def x(): from math import *',
Expand Down Expand Up @@ -229,7 +228,6 @@ def build_nested(code, depth, base='def f():\n'):
'async def foo():\n yield x\n return 1',
'async def foo():\n yield x\n return 1',

'[*[] for a in [1]]',
'async def bla():\n def x(): await bla()',
'del None',
'del True',
Expand Down Expand Up @@ -423,3 +421,10 @@ def y():
FAILING_EXAMPLES += [
'from .__future__ import whatever',
]

if sys.version_info[:2] < (3, 15):
# these nested expression successfully evaluate with 3.15
FAILING_EXAMPLES += [
'[*[] for a in [1]]',
'{**{} for a in [1]}',
]
8 changes: 6 additions & 2 deletions test/test_python_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,13 @@ def test_named_argument_issues(works_not_in_py):
message = works_not_in_py.get_error_message('def foo(*, **dict): pass')
message = works_not_in_py.get_error_message('def foo(*): pass')
if works_not_in_py.version.startswith('2'):
assert message == 'SyntaxError: invalid syntax'
wanted = 'SyntaxError: invalid syntax'
else:
assert message == 'SyntaxError: named arguments must follow bare *'
if sys.version_info[:2] < (3, 15):
wanted = 'SyntaxError: named arguments must follow bare *'
else:
wanted = 'SyntaxError: named parameters must follow bare *'
assert message == wanted

works_not_in_py.assert_no_error_in_passing('def foo(*, name): pass')
works_not_in_py.assert_no_error_in_passing('def foo(bar, *, name=1): pass')
Expand Down
Loading