def _adjust_arg(tokens, i, arg):
# Adjust `arg` to be the position of the first element.
# listcomps, generators, and tuples already point to the first element
if isinstance(arg, ast.List) and not isinstance(arg.elts[0], ast.Tuple):
arg = arg.elts[0]
elif isinstance(arg, ast.List):
# If the first element is a tuple, the ast lies to us about its col
# offset. We must find the first `(` token after the start of the
# list element.
while not _is_arg(tokens[i], arg):
i += 1
while tokens[i].src != '(':
i += 1
arg = copy.copy(arg.elts[0])
arg.lineno = tokens[i].line
arg.col_offset = tokens[i].utf8_byte_offset
return arg
评论列表
文章目录