Merge pull request #116 from isidentical/forbidden-name

Raise violation on starred expressions where the child is a boolean/none
This commit is contained in:
Dave Halter
2020-05-23 11:51:08 +02:00
committed by GitHub
3 changed files with 25 additions and 7 deletions

View File

@@ -981,6 +981,8 @@ class _CheckAssignmentRule(SyntaxRule):
or '_test' in type_ or '_test' in type_
or type_ in ('term', 'factor')): or type_ in ('term', 'factor')):
error = 'operator' error = 'operator'
elif type_ == "star_expr":
self._check_assignment(node.children[1])
if error is not None: if error is not None:
if is_namedexpr: if is_namedexpr:

View File

@@ -12,13 +12,6 @@ from .__future__ import absolute_import
''r''u'' ''r''u''
b'' BR'' b'' BR''
for x in [1]:
try:
continue # Only the other continue and pass is an error.
finally:
#: E901
continue
for x in [1]: for x in [1]:
break break

View File

@@ -339,3 +339,26 @@ def test_continue_in_finally():
assert _get_error_list(code, version="3.7") assert _get_error_list(code, version="3.7")
@pytest.mark.parametrize(
'template', [
"a, b, {target}, c = d",
"a, b, *{target}, c = d",
"(a, *{target}), c = d",
"for x, {target} in y: pass",
"for x, q, {target} in y: pass",
"for x, q, *{target} in y: pass",
"for (x, *{target}), q in y: pass",
]
)
@pytest.mark.parametrize(
'target', [
"True",
"False",
"None",
"__debug__"
]
)
def test_forbidden_name(template, target):
assert _get_error_list(template.format(target=target), version="3")[0].message