diff options
author | Florian Best <best@univention.de> | 2021-09-17 00:06:05 +0200 |
---|---|---|
committer | Anthony Sottile <asottile@umich.edu> | 2021-10-05 19:43:45 -0400 |
commit | f1d28848c34d5d8a773896c531c12390a7192508 (patch) | |
tree | 5c150ed2b496f4648e143a8c4378cc03919381ee | |
parent | 174ec0231955ba99cc2fdf48e61064b3f95c959c (diff) | |
download | pep8-f1d28848c34d5d8a773896c531c12390a7192508.tar.gz |
Issue #588: E201: detect tabs as whitespace
-rwxr-xr-x | pycodestyle.py | 4 | ||||
-rw-r--r-- | testsuite/E20.py | 23 |
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 |