summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2021-10-05 16:46:55 -0700
committerGitHub <noreply@github.com>2021-10-05 16:46:55 -0700
commit6f01bda37924c362ebd0d342a20c586548f35b46 (patch)
tree5c150ed2b496f4648e143a8c4378cc03919381ee
parent174ec0231955ba99cc2fdf48e61064b3f95c959c (diff)
parentf1d28848c34d5d8a773896c531c12390a7192508 (diff)
downloadpep8-6f01bda37924c362ebd0d342a20c586548f35b46.tar.gz
Merge pull request #1015 from spaceone/e201-tab-whitespace
Issue #588: E201: detect tabs as whitespace
-rwxr-xr-xpycodestyle.py4
-rw-r--r--testsuite/E20.py23
2 files changed, 25 insertions, 2 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index cc1720e..ca6a2bd 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -144,7 +144,7 @@ RAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*,')
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')
@@ -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] != ',':
diff --git a/testsuite/E20.py b/testsuite/E20.py
index 2f1ecc2..20c6dfd 100644
--- a/testsuite/E20.py
+++ b/testsuite/E20.py
@@ -4,6 +4,12 @@ spam( ham[1], {eggs: 2})
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})
#:
@@ -15,6 +21,12 @@ spam(ham[1], {eggs: 2} )
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})
@@ -39,13 +51,24 @@ result = [
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