Skip to content

Commit 6961709

Browse files
committed
Fix false-positive with star pattern
1 parent aa3417b commit 6961709

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
@@ -964,8 +964,13 @@ def missing_whitespace_around_operator(logical_line, tokens):
964964
# Check if the operator is used as a binary operator
965965
# Allow unary operators: -123, -x, +1.
966966
# Allow argument unpacking: foo(*args, **kwargs).
967-
if (prev_text in '}])' if prev_type == tokenize.OP
968-
else prev_text not in KEYWORDS):
967+
if prev_type == tokenize.OP and prev_text in '}])' or (
968+
prev_type != tokenize.OP and
969+
prev_text not in KEYWORDS and (
970+
sys.version_info < (3, 9) or
971+
not keyword.issoftkeyword(prev_text)
972+
)
973+
):
969974
need_space = None
970975
elif text in WS_OPTIONAL_OPERATORS:
971976
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)