@@ -119,7 +119,8 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
119
119
FUNCTION_RETURN_ANNOTATION_OP = ['->' ] if sys .version_info >= (3 , 5 ) else []
120
120
WS_NEEDED_OPERATORS = frozenset ([
121
121
'**=' , '*=' , '/=' , '//=' , '+=' , '-=' , '!=' , '<>' , '<' , '>' ,
122
- '%=' , '^=' , '&=' , '|=' , '==' , '<=' , '>=' , '<<=' , '>>=' , '=' ] +
122
+ '%=' , '^=' , '&=' , '|=' , '==' , '<=' , '>=' , '<<=' , '>>=' , '=' ,
123
+ 'and' , 'in' , 'is' , 'or' ] +
123
124
FUNCTION_RETURN_ANNOTATION_OP )
124
125
WHITESPACE = frozenset (' \t ' )
125
126
NEWLINE = frozenset ([tokenize .NL , tokenize .NEWLINE ])
@@ -824,6 +825,7 @@ def missing_whitespace_around_operator(logical_line, tokens):
824
825
E225: submitted +=1
825
826
E225: x = x /2 - 1
826
827
E225: z = x **y
828
+ E225: z = 1and 1
827
829
E226: c = (a+b) * (a-b)
828
830
E226: hypot2 = x*x + y*y
829
831
E227: c = a|b
@@ -833,6 +835,7 @@ def missing_whitespace_around_operator(logical_line, tokens):
833
835
need_space = False
834
836
prev_type = tokenize .OP
835
837
prev_text = prev_end = None
838
+ operator_types = (tokenize .OP , tokenize .NAME )
836
839
for token_type , text , start , end , line in tokens :
837
840
if token_type in SKIP_COMMENTS :
838
841
continue
@@ -864,7 +867,7 @@ def missing_whitespace_around_operator(logical_line, tokens):
864
867
yield (need_space [0 ], "%s missing whitespace "
865
868
"around %s operator" % (code , optype ))
866
869
need_space = False
867
- elif token_type == tokenize . OP and prev_end is not None :
870
+ elif token_type in operator_types and prev_end is not None :
868
871
if text == '=' and parens :
869
872
# Allow keyword args or defaults: foo(bar=None).
870
873
pass
0 commit comments