@@ -119,7 +119,8 @@ def lru_cache(maxsize=128): # noqa as it's a fake implementation.
119119FUNCTION_RETURN_ANNOTATION_OP = ['->' ] if sys .version_info >= (3 , 5 ) else []
120120WS_NEEDED_OPERATORS = frozenset ([
121121 '**=' , '*=' , '/=' , '//=' , '+=' , '-=' , '!=' , '<>' , '<' , '>' ,
122- '%=' , '^=' , '&=' , '|=' , '==' , '<=' , '>=' , '<<=' , '>>=' , '=' ] +
122+ '%=' , '^=' , '&=' , '|=' , '==' , '<=' , '>=' , '<<=' , '>>=' , '=' ,
123+ 'and' , 'in' , 'is' , 'or' ] +
123124 FUNCTION_RETURN_ANNOTATION_OP )
124125WHITESPACE = frozenset (' \t ' )
125126NEWLINE = frozenset ([tokenize .NL , tokenize .NEWLINE ])
@@ -824,6 +825,7 @@ def missing_whitespace_around_operator(logical_line, tokens):
824825 E225: submitted +=1
825826 E225: x = x /2 - 1
826827 E225: z = x **y
828+ E225: z = 1and 1
827829 E226: c = (a+b) * (a-b)
828830 E226: hypot2 = x*x + y*y
829831 E227: c = a|b
@@ -833,6 +835,7 @@ def missing_whitespace_around_operator(logical_line, tokens):
833835 need_space = False
834836 prev_type = tokenize .OP
835837 prev_text = prev_end = None
838+ operator_types = (tokenize .OP , tokenize .NAME )
836839 for token_type , text , start , end , line in tokens :
837840 if token_type in SKIP_COMMENTS :
838841 continue
@@ -864,7 +867,7 @@ def missing_whitespace_around_operator(logical_line, tokens):
864867 yield (need_space [0 ], "%s missing whitespace "
865868 "around %s operator" % (code , optype ))
866869 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 :
868871 if text == '=' and parens :
869872 # Allow keyword args or defaults: foo(bar=None).
870873 pass
0 commit comments