def _get_index_and_key(nodes, position):
 nodes_before = [c for c in nodes if (c.start_pos < position)]
 if (nodes_before[(-1)].type == 'arglist'):
  nodes_before = [c for c in nodes_before[(-1)].children if (c.start_pos < position)]
 key_str = None
 if nodes_before:
  last = nodes_before[(-1)]
  if ((last.type == 'argument') and (last.children[1].end_pos <= position)):
   key_str = last.children[0].value
  elif (last == '='):
   key_str = nodes_before[(-2)].value
 return (nodes_before.count(','), key_str)

def _get_index_and_key ( nodes , position ) : nodes_before = [ c for c in nodes if ( c . start_pos < position ) ] if ( nodes_before [ ( - 1 ) ] . type == 'arglist' ) : nodes_before = [ c for c in nodes_before [ ( - 1 ) ] . children if ( c . start_pos < position ) ] key_str = None if nodes_before : last = nodes_before [ ( - 1 ) ] if ( ( last . type == 'argument' ) and ( last . children [ 1 ] . end_pos <= position ) ) : key_str = last . children [ 0 ] . value elif ( last == '=' ) : key_str = nodes_before [ ( - 2 ) ] . value return ( nodes_before . count ( ',' ) , key_str )
returns the amount of commas and the keyword argument string .