diff options
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-x | pycodestyle.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index c091639..1ceff9e 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -811,14 +811,21 @@ def whitespace_before_parameters(logical_line, tokens): prev_type, prev_text, __, prev_end, __ = tokens[0] for index in range(1, len(tokens)): token_type, text, start, end, __ = tokens[index] - if (token_type == tokenize.OP and + if ( + token_type == tokenize.OP and text in '([' and start != prev_end and (prev_type == tokenize.NAME or prev_text in '}])') and # Syntax "class A (B):" is allowed, but avoid it (index < 2 or tokens[index - 2][1] != 'class') and - # Allow "return (a.foo for a in range(5))" - not keyword.iskeyword(prev_text)): + # Allow "return (a.foo for a in range(5))" + not keyword.iskeyword(prev_text) and + # 'match' and 'case' are only soft keywords + ( + sys.version_info <= (3, 10) or + not keyword.issoftkeyword(prev_text) + ) + ): yield prev_end, "E211 whitespace before '%s'" % text prev_type = token_type prev_text = text |