Skip to content

Commit 6f01bda

Browse files
authored
Merge pull request PyCQA#1015 from spaceone/e201-tab-whitespace
Issue PyCQA#588: E201: detect tabs as whitespace
2 parents 174ec02 + f1d2884 commit 6f01bda

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

pycodestyle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
144144
RERAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,.*,\s*\w+\s*$')
145145
ERRORCODE_REGEX = re.compile(r'\b[A-Z]\d{3}\b')
146146
DOCSTRING_REGEX = re.compile(r'u?r?["\']')
147-
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[\[({] | [\]}),;]| :(?!=)')
147+
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[\[({][ \t]|[ \t][\]}),;:](?!=)')
148148
WHITESPACE_AFTER_COMMA_REGEX = re.compile(r'[,;:]\s*(?: |\t)')
149149
COMPARE_SINGLETON_REGEX = re.compile(r'(\bNone|\bFalse|\bTrue)?\s*([=!]=)'
150150
r'\s*(?(1)|(None|False|True))\b')
@@ -471,7 +471,7 @@ def extraneous_whitespace(logical_line):
471471
text = match.group()
472472
char = text.strip()
473473
found = match.start()
474-
if text == char + ' ':
474+
if text[-1].isspace():
475475
# assert char in '([{'
476476
yield found + 1, "E201 whitespace after '%s'" % char
477477
elif line[found - 1] != ',':

testsuite/E20.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
spam(ham[ 1], {eggs: 2})
55
#: E201:1:15
66
spam(ham[1], { eggs: 2})
7+
#: E201:1:6
8+
spam( ham[1], {eggs: 2})
9+
#: E201:1:10
10+
spam(ham[ 1], {eggs: 2})
11+
#: E201:1:15
12+
spam(ham[1], { eggs: 2})
713
#: Okay
814
spam(ham[1], {eggs: 2})
915
#:
@@ -15,6 +21,12 @@
1521
spam(ham[1], {eggs: 2 })
1622
#: E202:1:11
1723
spam(ham[1 ], {eggs: 2})
24+
#: E202:1:23
25+
spam(ham[1], {eggs: 2} )
26+
#: E202:1:22
27+
spam(ham[1], {eggs: 2 })
28+
#: E202:1:11
29+
spam(ham[1 ], {eggs: 2})
1830
#: Okay
1931
spam(ham[1], {eggs: 2})
2032

@@ -39,13 +51,24 @@
3951
if x == 4 :
4052
print x, y
4153
x, y = y, x
54+
#: E203:1:10
55+
if x == 4 :
56+
print x, y
57+
x, y = y, x
4258
#: E203:2:15 E702:2:16
4359
if x == 4:
4460
print x, y ; x, y = y, x
61+
#: E203:2:15 E702:2:16
62+
if x == 4:
63+
print x, y ; x, y = y, x
4564
#: E203:3:13
4665
if x == 4:
4766
print x, y
4867
x, y = y , x
68+
#: E203:3:13
69+
if x == 4:
70+
print x, y
71+
x, y = y , x
4972
#: Okay
5073
if x == 4:
5174
print x, y

0 commit comments

Comments
 (0)