def explicit_line_join(logical_line, tokens):
 prev_start = prev_end = parens = 0
 backslash = None
 for (token_type, text, start, end, line) in tokens:
  if ((start[0] != prev_start) and parens and backslash):
   (yield (backslash, 'E502 the backslash is redundant between brackets'))
  if (end[0] != prev_end):
   if line.rstrip('\r\n').endswith('\\'):
    backslash = (end[0], (len(line.splitlines()[(-1)]) - 1))
   else:
    backslash = None
   prev_start = prev_end = end[0]
  else:
   prev_start = start[0]
  if (token_type == tokenize.OP):
   if (text in '([{'):
    parens += 1
   elif (text in ')]}'):
    parens -= 1

def explicit_line_join ( logical_line , tokens ) : prev_start = prev_end = parens = 0 backslash = None for ( token_type , text , start , end , line ) in tokens : if ( ( start [ 0 ] != prev_start ) and parens and backslash ) : ( yield ( backslash , 'E502 the backslash is redundant between brackets' ) ) if ( end [ 0 ] != prev_end ) : if line . rstrip ( '\r\n' ) . endswith ( '\\' ) : backslash = ( end [ 0 ] , ( len ( line . splitlines ( ) [ ( - 1 ) ] ) - 1 ) ) else : backslash = None prev_start = prev_end = end [ 0 ] else : prev_start = start [ 0 ] if ( token_type == tokenize . OP ) : if ( text in '([{' ) : parens += 1 elif ( text in ')]}' ) : parens -= 1
avoid explicit line join between brackets .