Skip to content

Commit

Permalink
Merge pull request #1003 from cdce8p/e225-star-pattern
Browse files Browse the repository at this point in the history
Fix false-positive with star pattern
  • Loading branch information
asottile committed Oct 5, 2021
2 parents 7046878 + 6961709 commit 174ec02
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,13 @@ def missing_whitespace_around_operator(logical_line, tokens):
# Check if the operator is used as a binary operator
# Allow unary operators: -123, -x, +1.
# Allow argument unpacking: foo(*args, **kwargs).
if (prev_text in '}])' if prev_type == tokenize.OP
else prev_text not in KEYWORDS):
if prev_type == tokenize.OP and prev_text in '}])' or (
prev_type != tokenize.OP and
prev_text not in KEYWORDS and (
sys.version_info < (3, 9) or
not keyword.issoftkeyword(prev_text)
)
):
need_space = None
elif text in WS_OPTIONAL_OPERATORS:
need_space = None
Expand Down
15 changes: 15 additions & 0 deletions testsuite/python310.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
pass
case _:
print("Default")
#: Okay
var = 0, 1, 2
match var:
case *_, 1, 2:
pass
case 0, *_, 2:
pass
case 0, 1, *_:
pass
case (*_, 1, 2):
pass
case (0, *_, 2):
pass
case (0, 1, *_):
pass
#: E271:2:6 E271:3:9 E271:5:9 E271:7:9
var = 1
match var:
Expand Down

0 comments on commit 174ec02

Please sign in to comment.