mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 13:45:01 +08:00
Add issue: Generator expression must be parenthesized if not sole argument
This commit is contained in:
@@ -141,6 +141,14 @@ class ErrorFinder(Normalizer):
|
|||||||
and not self._context.is_async_funcdef():
|
and not self._context.is_async_funcdef():
|
||||||
message = "asynchronous comprehension outside of an asynchronous function"
|
message = "asynchronous comprehension outside of an asynchronous function"
|
||||||
self._add_syntax_error(message, node)
|
self._add_syntax_error(message, node)
|
||||||
|
elif node.type == 'arglist':
|
||||||
|
first_arg = node.children[0]
|
||||||
|
if first_arg.type == 'argument' \
|
||||||
|
and first_arg.children[1].type == 'comp_for' \
|
||||||
|
and len(node.children) >= 2:
|
||||||
|
# foo(x for x in [], b)
|
||||||
|
message = "Generator expression must be parenthesized if not sole argument"
|
||||||
|
self._add_syntax_error(message, node)
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ def test_indentation_errors(code, positions):
|
|||||||
'return',
|
'return',
|
||||||
'yield',
|
'yield',
|
||||||
'try: pass\nexcept: pass\nexcept X: pass',
|
'try: pass\nexcept: pass\nexcept X: pass',
|
||||||
|
'f(x for x in bar, 1)',
|
||||||
|
|
||||||
# IndentationError
|
# IndentationError
|
||||||
' foo',
|
' foo',
|
||||||
|
|||||||
Reference in New Issue
Block a user