Skip to content

Commit 174ec02

Browse files
authored
Merge pull request PyCQA#1003 from cdce8p/e225-star-pattern
Fix false-positive with star pattern
2 parents 7046878 + 6961709 commit 174ec02

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

pycodestyle.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,13 @@ def missing_whitespace_around_operator(logical_line, tokens):
965965
# Check if the operator is used as a binary operator
966966
# Allow unary operators: -123, -x, +1.
967967
# Allow argument unpacking: foo(*args, **kwargs).
968-
if (prev_text in '}])' if prev_type == tokenize.OP
969-
else prev_text not in KEYWORDS):
968+
if prev_type == tokenize.OP and prev_text in '}])' or (
969+
prev_type != tokenize.OP and
970+
prev_text not in KEYWORDS and (
971+
sys.version_info < (3, 9) or
972+
not keyword.issoftkeyword(prev_text)
973+
)
974+
):
970975
need_space = None
971976
elif text in WS_OPTIONAL_OPERATORS:
972977
need_space = None

testsuite/python310.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77
pass
88
case _:
99
print("Default")
10+
#: Okay
11+
var = 0, 1, 2
12+
match var:
13+
case *_, 1, 2:
14+
pass
15+
case 0, *_, 2:
16+
pass
17+
case 0, 1, *_:
18+
pass
19+
case (*_, 1, 2):
20+
pass
21+
case (0, *_, 2):
22+
pass
23+
case (0, 1, *_):
24+
pass
1025
#: E271:2:6 E271:3:9 E271:5:9 E271:7:9
1126
var = 1
1227
match var:

0 commit comments

Comments
 (0)