From 696170927b2723ce390d011d5d1af34e914e61b8 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 9 Jul 2021 17:19:44 +0200 Subject: Fix false-positive with star pattern --- pycodestyle.py | 9 +++++++-- testsuite/python310.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pycodestyle.py b/pycodestyle.py index 0d8ed50..b00b1f1 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -964,8 +964,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 diff --git a/testsuite/python310.py b/testsuite/python310.py index e78d372..8cd98f2 100644 --- a/testsuite/python310.py +++ b/testsuite/python310.py @@ -7,6 +7,21 @@ match (var, var2): 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: -- cgit v1.2.1