def comparison_to_singleton(logical_line, noqa):
 match = ((not noqa) and COMPARE_SINGLETON_REGEX.search(logical_line))
 if match:
  singleton = (match.group(1) or match.group(3))
  same = (match.group(2) == '==')
  msg = ("'if cond is %s:'" % (('' if same else 'not ') + singleton))
  if (singleton in ('None',)):
   code = 'E711'
  else:
   code = 'E712'
   nonzero = (((singleton == 'True') and same) or ((singleton == 'False') and (not same)))
   msg += (" or 'if %scond:'" % ('' if nonzero else 'not '))
  (yield (match.start(2), ('%s comparison to %s should be %s' % (code, singleton, msg))))

def comparison_to_singleton ( logical_line , noqa ) : match = ( ( not noqa ) and COMPARE_SINGLETON_REGEX . search ( logical_line ) ) if match : singleton = ( match . group ( 1 ) or match . group ( 3 ) ) same = ( match . group ( 2 ) == '==' ) msg = ( "'if cond is %s:'" % ( ( '' if same else 'not ' ) + singleton ) ) if ( singleton in ( 'None' , ) ) : code = 'E711' else : code = 'E712' nonzero = ( ( ( singleton == 'True' ) and same ) or ( ( singleton == 'False' ) and ( not same ) ) ) msg += ( " or 'if %scond:'" % ( '' if nonzero else 'not ' ) ) ( yield ( match . start ( 2 ) , ( '%s comparison to %s should be %s' % ( code , singleton , msg ) ) ) )
comparison to singletons should use "is" or "is not" .