Skip to content

Commit

Permalink
Merge pull request #1015 from spaceone/e201-tab-whitespace
Browse files Browse the repository at this point in the history
Issue #588: E201: detect tabs as whitespace
  • Loading branch information
asottile committed Oct 5, 2021
2 parents 174ec02 + f1d2884 commit 6f01bda
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
RERAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,.*,\s*\w+\s*$')
ERRORCODE_REGEX = re.compile(r'\b[A-Z]\d{3}\b')
DOCSTRING_REGEX = re.compile(r'u?r?["\']')
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[\[({] | [\]}),;]| :(?!=)')
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[\[({][ \t]|[ \t][\]}),;:](?!=)')
WHITESPACE_AFTER_COMMA_REGEX = re.compile(r'[,;:]\s*(?: |\t)')
COMPARE_SINGLETON_REGEX = re.compile(r'(\bNone|\bFalse|\bTrue)?\s*([=!]=)'
r'\s*(?(1)|(None|False|True))\b')
Expand Down Expand Up @@ -471,7 +471,7 @@ def extraneous_whitespace(logical_line):
text = match.group()
char = text.strip()
found = match.start()
if text == char + ' ':
if text[-1].isspace():
# assert char in '([{'
yield found + 1, "E201 whitespace after '%s'" % char
elif line[found - 1] != ',':
Expand Down
23 changes: 23 additions & 0 deletions testsuite/E20.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
spam(ham[ 1], {eggs: 2})
#: E201:1:15
spam(ham[1], { eggs: 2})
#: E201:1:6
spam( ham[1], {eggs: 2})
#: E201:1:10
spam(ham[ 1], {eggs: 2})
#: E201:1:15
spam(ham[1], { eggs: 2})
#: Okay
spam(ham[1], {eggs: 2})
#:
Expand All @@ -15,6 +21,12 @@
spam(ham[1], {eggs: 2 })
#: E202:1:11
spam(ham[1 ], {eggs: 2})
#: E202:1:23
spam(ham[1], {eggs: 2} )
#: E202:1:22
spam(ham[1], {eggs: 2 })
#: E202:1:11
spam(ham[1 ], {eggs: 2})
#: Okay
spam(ham[1], {eggs: 2})

Expand All @@ -39,13 +51,24 @@
if x == 4 :
print x, y
x, y = y, x
#: E203:1:10
if x == 4 :
print x, y
x, y = y, x
#: E203:2:15 E702:2:16
if x == 4:
print x, y ; x, y = y, x
#: E203:2:15 E702:2:16
if x == 4:
print x, y ; x, y = y, x
#: E203:3:13
if x == 4:
print x, y
x, y = y , x
#: E203:3:13
if x == 4:
print x, y
x, y = y , x
#: Okay
if x == 4:
print x, y
Expand Down

0 comments on commit 6f01bda

Please sign in to comment.