parameters: (self, result)
docstring: Fix (trivial case of) comparison with boolean.
docstring_summary: Fix (trivial case of) comparison with boolean.
docstring_tokens: Fix ( trivial case of ) comparison with boolean .
function: def fix_e712(self, result):
          """Fix (trivial case of) comparison with boolean."""
          (line_index, offset, target) = get_index_offset_contents(result,
                                                                   self.source)
  
          # Handle very easy "not" special cases.
          if re.match(r'^\s*if [\w.]+ == False:$', target):
              self.source[line_index] = re.sub(r'if ([\w.]+) == False:',
                                               r'if not \1:', target, count=1)
          elif re.match(r'^\s*if [\w.]+ != True:$', target):
              self.source[line_index] = re.sub(r'if ([\w.]+) != True:',
                                               r'if not \1:', target, count=1)
          else:
              right_offset = offset + 2
              if right_offset >= len(target):
                  return []
  
              left = target[:offset].rstrip()
              center = target[offset:right_offset]
              right = target[right_offset:].lstrip()
  
              # Handle simple cases only.
              new_right = None
              if center.strip() == '==':
                  if re.match(r'\bTrue\b', right):
                      new_right = re.sub(r'\bTrue\b *', '', right, count=1)
              elif center.strip() == '!=':
                  if re.match(r'\bFalse\b', right):
                      new_right = re.sub(r'\bFalse\b *', '', right, count=1)
  
              if new_right is None:
                  return []
  
              if new_right[0].isalnum():
                  new_right = ' ' + new_right
  
              self.source[line_index] = left + new_right
function_tokens: def fix_e712 ( self , result ) : ( line_index , offset , target ) = get_index_offset_contents ( result , self . source ) # Handle very easy "not" special cases. if re . match ( r'^\s*if [\w.]+ == False:$' , target ) : self . source [ line_index ] = re . sub ( r'if ([\w.]+) == False:' , r'if not \1:' , target , count = 1 ) elif re . match ( r'^\s*if [\w.]+ != True:$' , target ) : self . source [ line_index ] = re . sub ( r'if ([\w.]+) != True:' , r'if not \1:' , target , count = 1 ) else : right_offset = offset + 2 if right_offset >= len ( target ) : return [ ] left = target [ : offset ] . rstrip ( ) center = target [ offset : right_offset ] right = target [ right_offset : ] . lstrip ( ) # Handle simple cases only. new_right = None if center . strip ( ) == '==' : if re . match ( r'\bTrue\b' , right ) : new_right = re . sub ( r'\bTrue\b *' , '' , right , count = 1 ) elif center . strip ( ) == '!=' : if re . match ( r'\bFalse\b' , right ) : new_right = re . sub ( r'\bFalse\b *' , '' , right , count = 1 ) if new_right is None : return [ ] if new_right [ 0 ] . isalnum ( ) : new_right = ' ' + new_right self . source [ line_index ] = left + new_right