Skip to content

Commit abc475c

Browse files
authored
Merge pull request #1032 from cdce8p/walrus-multiple-spaces
Emit E221-E224 for walrus op
2 parents c2ec413 + d17c08b commit abc475c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pycodestyle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
152152
COMPARE_TYPE_REGEX = re.compile(r'(?:[=!]=|is(?:\s+not)?)\s+type(?:s.\w+Type'
153153
r'|\s*\(\s*([^)]*[^ )])\s*\))')
154154
KEYWORD_REGEX = re.compile(r'(\s*)\b(?:%s)\b(\s*)' % r'|'.join(KEYWORDS))
155-
OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)')
155+
OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+|:=)(\s*)')
156156
LAMBDA_REGEX = re.compile(r'\blambda\b')
157157
HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$')
158158
STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)\b')

testsuite/python38.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,14 @@ def f3(
4242
all_the_things: t.List[str] = []
4343

4444
import logging
45+
#: E221:1:5 E222:1:9 E221:3:6
46+
if x := 1:
47+
pass
48+
if (x := 2):
49+
pass
50+
#: E223:1:5 E224:1:8
51+
if x := 2:
52+
pass
53+
#: E221:1:6 E221:1:19
54+
if (x := 1) == (y := 2):
55+
pass

0 commit comments

Comments
 (0)