mirror of
https://github.com/davidhalter/parso.git
synced 2026-08-12 10:54:59 +08:00
Support more Python 3.15 exception changes (#241)
Build / lint (push) Canceled after 0s
Build / test (false, 3.10) (push) Canceled after 0s
Build / test (false, 3.11) (push) Canceled after 0s
Build / test (false, 3.12) (push) Canceled after 0s
Build / test (false, 3.13) (push) Canceled after 0s
Build / test (false, 3.8) (push) Canceled after 0s
Build / test (false, 3.9) (push) Canceled after 0s
Build / coverage (push) Canceled after 0s
Build / lint (push) Canceled after 0s
Build / test (false, 3.10) (push) Canceled after 0s
Build / test (false, 3.11) (push) Canceled after 0s
Build / test (false, 3.12) (push) Canceled after 0s
Build / test (false, 3.13) (push) Canceled after 0s
Build / test (false, 3.8) (push) Canceled after 0s
Build / test (false, 3.9) (push) Canceled after 0s
Build / coverage (push) Canceled after 0s
Python 3.15 changed the wording of some SyntaxError exceptions to make it clearer. The previous PR only fixed one instance.
This commit is contained in:
@@ -659,7 +659,10 @@ class _StringChecks(SyntaxRule):
|
|||||||
|
|
||||||
@ErrorFinder.register_rule(value='*')
|
@ErrorFinder.register_rule(value='*')
|
||||||
class _StarCheck(SyntaxRule):
|
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):
|
def is_issue(self, leaf):
|
||||||
params = leaf.parent
|
params = leaf.parent
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ FAILING_EXAMPLES = [
|
|||||||
'del *a, b',
|
'del *a, b',
|
||||||
'def x(*): pass',
|
'def x(*): pass',
|
||||||
'(%s *d) = x' % ('a,' * 256),
|
'(%s *d) = x' % ('a,' * 256),
|
||||||
'{**{} for a in [1]}',
|
|
||||||
'(True,) = x',
|
'(True,) = x',
|
||||||
'([False], a) = x',
|
'([False], a) = x',
|
||||||
'def x(): from math import *',
|
'def x(): from math import *',
|
||||||
@@ -229,7 +228,6 @@ FAILING_EXAMPLES = [
|
|||||||
'async def foo():\n yield x\n return 1',
|
'async def foo():\n yield x\n return 1',
|
||||||
'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()',
|
'async def bla():\n def x(): await bla()',
|
||||||
'del None',
|
'del None',
|
||||||
'del True',
|
'del True',
|
||||||
@@ -423,3 +421,10 @@ if sys.version_info[:2] < (3, 13):
|
|||||||
FAILING_EXAMPLES += [
|
FAILING_EXAMPLES += [
|
||||||
'from .__future__ import whatever',
|
'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]}',
|
||||||
|
]
|
||||||
|
|||||||
@@ -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(*, **dict): pass')
|
||||||
message = works_not_in_py.get_error_message('def foo(*): pass')
|
message = works_not_in_py.get_error_message('def foo(*): pass')
|
||||||
if works_not_in_py.version.startswith('2'):
|
if works_not_in_py.version.startswith('2'):
|
||||||
assert message == 'SyntaxError: invalid syntax'
|
wanted = 'SyntaxError: invalid syntax'
|
||||||
else:
|
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(*, name): pass')
|
||||||
works_not_in_py.assert_no_error_in_passing('def foo(bar, *, name=1): pass')
|
works_not_in_py.assert_no_error_in_passing('def foo(bar, *, name=1): pass')
|
||||||
|
|||||||
Reference in New Issue
Block a user