diff options
author | Anthony Sottile <asottile@umich.edu> | 2022-11-05 23:44:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-05 23:44:59 -0400 |
commit | c14a26328f93815ed546c2b5c09d3a8f9addea95 (patch) | |
tree | 40a625c7f258746a1edae25b20f8fcf2884b2a19 | |
parent | 2b76c4da9a1687cb6ca8eeb625b95b3fbdcf7bad (diff) | |
parent | a13131627c67db9e422c203f391a74b3ca7315a8 (diff) | |
download | pep8-c14a26328f93815ed546c2b5c09d3a8f9addea95.tar.gz |
Merge pull request #1118 from dannysepler/E741-false-pos
Fix false positive with E741
-rwxr-xr-x | pycodestyle.py | 3 | ||||
-rw-r--r-- | testsuite/python38.py | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index 29f93ea..a105a0f 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -1504,6 +1504,7 @@ def ambiguous_identifier(logical_line, tokens): Okay: lambda arg: arg * l Okay: lambda a=l[I:5]: None Okay: lambda x=a.I: None + Okay: if l >= 12: E741: except AttributeError as O: E741: with lock as l: E741: global I @@ -1542,7 +1543,7 @@ def ambiguous_identifier(logical_line, tokens): elif text == ')': parameter_parentheses_level -= 1 # identifiers on the lhs of an assignment operator - if token_type == tokenize.OP and '=' in text and \ + if token_type == tokenize.OP and text in {'=', ':='} and \ parameter_parentheses_level == 0: if prev_text in idents_to_avoid: ident = prev_text diff --git a/testsuite/python38.py b/testsuite/python38.py index 8bf0d4d..faf9aa7 100644 --- a/testsuite/python38.py +++ b/testsuite/python38.py @@ -53,3 +53,6 @@ if x := 2: #: E221:1:6 E221:1:19 if (x := 1) == (y := 2): pass +#: E741 +while l := 1: + pass |