mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 05:34:51 +08:00
Small improvements.
This commit is contained in:
@@ -203,7 +203,8 @@ class ErrorFinder(Normalizer):
|
|||||||
params = leaf.parent
|
params = leaf.parent
|
||||||
if params.type == 'parameters' and params:
|
if params.type == 'parameters' and params:
|
||||||
after = params.children[params.children.index(leaf) + 1:]
|
after = params.children[params.children.index(leaf) + 1:]
|
||||||
after = [child for child in after if child not in (',', ')')]
|
after = [child for child in after
|
||||||
|
if child not in (',', ')') and not child.star_count]
|
||||||
if len(after) == 0:
|
if len(after) == 0:
|
||||||
self._add_syntax_error("named arguments must follow bare *", leaf)
|
self._add_syntax_error("named arguments must follow bare *", leaf)
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
@@ -177,9 +177,11 @@ def test_future_import_first():
|
|||||||
|
|
||||||
|
|
||||||
def test_named_argument_issues(works_not_in_py):
|
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')
|
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'):
|
||||||
message
|
message
|
||||||
|
|
||||||
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')
|
||||||
|
works_not_in_py.assert_no_error_in_passing('def foo(bar, *, name=1, **dct): pass')
|
||||||
|
|||||||
Reference in New Issue
Block a user