summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpycodestyle.py7
-rw-r--r--testsuite/E22.py8
2 files changed, 13 insertions, 2 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index 4a0d17b..02a717a 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -119,7 +119,8 @@ WS_OPTIONAL_OPERATORS = ARITHMETIC_OP.union(['^', '&', '|', '<<', '>>', '%'])
FUNCTION_RETURN_ANNOTATION_OP = ['->'] if sys.version_info >= (3, 5) else []
WS_NEEDED_OPERATORS = frozenset([
'**=', '*=', '/=', '//=', '+=', '-=', '!=', '<>', '<', '>',
- '%=', '^=', '&=', '|=', '==', '<=', '>=', '<<=', '>>=', '='] +
+ '%=', '^=', '&=', '|=', '==', '<=', '>=', '<<=', '>>=', '=',
+ 'and', 'in', 'is', 'or'] +
FUNCTION_RETURN_ANNOTATION_OP)
WHITESPACE = frozenset(' \t')
NEWLINE = frozenset([tokenize.NL, tokenize.NEWLINE])
@@ -824,6 +825,7 @@ def missing_whitespace_around_operator(logical_line, tokens):
E225: submitted +=1
E225: x = x /2 - 1
E225: z = x **y
+ E225: z = 1and 1
E226: c = (a+b) * (a-b)
E226: hypot2 = x*x + y*y
E227: c = a|b
@@ -833,6 +835,7 @@ def missing_whitespace_around_operator(logical_line, tokens):
need_space = False
prev_type = tokenize.OP
prev_text = prev_end = None
+ operator_types = (tokenize.OP, tokenize.NAME)
for token_type, text, start, end, line in tokens:
if token_type in SKIP_COMMENTS:
continue
@@ -864,7 +867,7 @@ def missing_whitespace_around_operator(logical_line, tokens):
yield (need_space[0], "%s missing whitespace "
"around %s operator" % (code, optype))
need_space = False
- elif token_type == tokenize.OP and prev_end is not None:
+ elif token_type in operator_types and prev_end is not None:
if text == '=' and parens:
# Allow keyword args or defaults: foo(bar=None).
pass
diff --git a/testsuite/E22.py b/testsuite/E22.py
index ee9dc74..4974cb3 100644
--- a/testsuite/E22.py
+++ b/testsuite/E22.py
@@ -76,6 +76,14 @@ _1kB = _1MB>> 10
i=i+ 1
#: E225 E225
i=i +1
+#: E225
+i = 1and 1
+#: E225
+i = 1or 0
+#: E225
+1is 1
+#: E225
+1in []
#: E225 E226
i=i+1
#: E225 E226