Add issue: Generator expression must be parenthesized if not sole argument

This commit is contained in:
Dave Halter
2017-07-23 22:56:19 +02:00
parent 42842a6949
commit 33769c6243
2 changed files with 9 additions and 0 deletions

View File

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

View File

@@ -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',