Skip to content

Commit a131316

Browse files
dannyseplerasottile
authored andcommitted
Fix false positive with E741
1 parent 2b76c4d commit a131316

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

pycodestyle.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,7 @@ def ambiguous_identifier(logical_line, tokens):
15041504
Okay: lambda arg: arg * l
15051505
Okay: lambda a=l[I:5]: None
15061506
Okay: lambda x=a.I: None
1507+
Okay: if l >= 12:
15071508
E741: except AttributeError as O:
15081509
E741: with lock as l:
15091510
E741: global I
@@ -1542,7 +1543,7 @@ def ambiguous_identifier(logical_line, tokens):
15421543
elif text == ')':
15431544
parameter_parentheses_level -= 1
15441545
# identifiers on the lhs of an assignment operator
1545-
if token_type == tokenize.OP and '=' in text and \
1546+
if token_type == tokenize.OP and text in {'=', ':='} and \
15461547
parameter_parentheses_level == 0:
15471548
if prev_text in idents_to_avoid:
15481549
ident = prev_text

testsuite/python38.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ def f3(
5353
#: E221:1:6 E221:1:19
5454
if (x := 1) == (y := 2):
5555
pass
56+
#: E741
57+
while l := 1:
58+
pass

0 commit comments

Comments
 (0)