forked from VimPlug/jedi
Removed tree.is_node.
It's not needed anymore, because we have Node/Leaf.type now.
This commit is contained in:
@@ -269,7 +269,7 @@ class Evaluator(object):
|
||||
def _eval_element_not_cached(self, context, element):
|
||||
debug.dbg('eval_element %s@%s', element, element.start_pos)
|
||||
types = set()
|
||||
if isinstance(element, (tree.Name, tree.Literal)) or tree.is_node(element, 'atom'):
|
||||
if isinstance(element, (tree.Name, tree.Literal)) or element.type == 'atom':
|
||||
types = self.eval_atom(context, element)
|
||||
elif isinstance(element, tree.Keyword):
|
||||
# For False/True/None
|
||||
@@ -358,7 +358,7 @@ class Evaluator(object):
|
||||
return types
|
||||
# Parentheses without commas are not tuples.
|
||||
elif c[0] == '(' and not len(c) == 2 \
|
||||
and not(tree.is_node(c[1], 'testlist_comp') and
|
||||
and not(c[1].type == 'testlist_comp' and
|
||||
len(c[1].children) > 1):
|
||||
return self.eval_element(context, c[1])
|
||||
|
||||
@@ -508,7 +508,7 @@ class Evaluator(object):
|
||||
for value in values
|
||||
)
|
||||
|
||||
if tree.is_node(par, 'trailer') and par.children[0] == '.':
|
||||
if par.type == 'trailer' and par.children[0] == '.':
|
||||
values = helpers.evaluate_call_of_leaf(context, name, cut_own_trailer=True)
|
||||
return unite(
|
||||
value.py__getattribute__(name, name_context=context, is_goto=True)
|
||||
|
||||
@@ -427,9 +427,9 @@ class SequenceLiteralContext(ArrayMixin, AbstractSequence):
|
||||
if array_node in (']', '}', ')'):
|
||||
return [] # Direct closing bracket, doesn't contain items.
|
||||
|
||||
if tree.is_node(array_node, 'testlist_comp'):
|
||||
if array_node.type == 'testlist_comp':
|
||||
return array_node.children[::2]
|
||||
elif tree.is_node(array_node, 'dictorsetmaker'):
|
||||
elif array_node.type == 'dictorsetmaker':
|
||||
kv = []
|
||||
iterator = iter(array_node.children)
|
||||
for key in iterator:
|
||||
@@ -889,14 +889,14 @@ def create_index_types(evaluator, context, index):
|
||||
if index == ':':
|
||||
# Like array[:]
|
||||
return set([Slice(context, None, None, None)])
|
||||
elif tree.is_node(index, 'subscript'): # subscript is a slice operation.
|
||||
elif index.type == 'subscript': # subscript is a slice operation.
|
||||
# Like array[:3]
|
||||
result = []
|
||||
for el in index.children:
|
||||
if el == ':':
|
||||
if not result:
|
||||
result.append(None)
|
||||
elif tree.is_node(el, 'sliceop'):
|
||||
elif el.type == 'sliceop':
|
||||
if len(el.children) == 2:
|
||||
result.append(el.children[1])
|
||||
else:
|
||||
|
||||
@@ -90,10 +90,10 @@ class TreeArguments(AbstractArguments):
|
||||
for el in self.argument_node:
|
||||
yield 0, el
|
||||
else:
|
||||
if not (tree.is_node(self.argument_node, 'arglist') or (
|
||||
if not (self.argument_node.type == 'arglist' or (
|
||||
# in python 3.5 **arg is an argument, not arglist
|
||||
(tree.is_node(self.argument_node, 'argument') and
|
||||
self.argument_node.children[0] in ('*', '**')))):
|
||||
(self.argument_node.type == 'argument') and
|
||||
self.argument_node.children[0] in ('*', '**'))):
|
||||
yield 0, self.argument_node
|
||||
return
|
||||
|
||||
@@ -103,7 +103,7 @@ class TreeArguments(AbstractArguments):
|
||||
continue
|
||||
elif child in ('*', '**'):
|
||||
yield len(child.value), next(iterator)
|
||||
elif tree.is_node(child, 'argument') and \
|
||||
elif child.type == 'argument' and \
|
||||
child.children[0] in ('*', '**'):
|
||||
assert len(child.children) == 2
|
||||
yield len(child.children[0].value), child.children[1]
|
||||
@@ -130,7 +130,7 @@ class TreeArguments(AbstractArguments):
|
||||
for key, values in _star_star_dict(self.context, dct, el, func):
|
||||
yield key, values
|
||||
else:
|
||||
if tree.is_node(el, 'argument'):
|
||||
if el.type == 'argument':
|
||||
c = el.children
|
||||
if len(c) == 3: # Keyword argument.
|
||||
named_args.append((c[0].value, context.LazyTreeContext(self.context, c[2]),))
|
||||
@@ -149,7 +149,7 @@ class TreeArguments(AbstractArguments):
|
||||
|
||||
def as_tree_tuple_objects(self):
|
||||
for stars, argument in self._split():
|
||||
if tree.is_node(argument, 'argument'):
|
||||
if argument.type == 'argument':
|
||||
argument, default = argument.children[::2]
|
||||
else:
|
||||
default = None
|
||||
|
||||
@@ -129,7 +129,7 @@ def py__getitem__(context, typ, node):
|
||||
# should be replaced by that class. This is not 100%
|
||||
# airtight but I don't have a better idea to check that it's
|
||||
# actually the PEP-0484 typing module and not some other
|
||||
if tree.is_node(node, "subscriptlist"):
|
||||
if node.type == "subscriptlist":
|
||||
nodes = node.children[::2] # skip the commas
|
||||
else:
|
||||
nodes = [node]
|
||||
|
||||
@@ -45,7 +45,7 @@ def calculate_children(evaluator, context, children):
|
||||
types = context.eval_node(next(iterator))
|
||||
for operator in iterator:
|
||||
right = next(iterator)
|
||||
if tree.is_node(operator, 'comp_op'): # not in / is not
|
||||
if operator.type == 'comp_op': # not in / is not
|
||||
operator = ' '.join(str(c.value) for c in operator.children)
|
||||
|
||||
# handle lazy evaluation of and/or here.
|
||||
|
||||
@@ -100,7 +100,7 @@ def _paths_from_assignment(module_context, expr_stmt):
|
||||
for assignee, operator in zip(expr_stmt.children[::2], expr_stmt.children[1::2]):
|
||||
try:
|
||||
assert operator in ['=', '+=']
|
||||
assert tree.is_node(assignee, 'power', 'atom_expr') and \
|
||||
assert assignee.type in ('power', 'atom_expr') and \
|
||||
len(assignee.children) > 1
|
||||
c = assignee.children
|
||||
assert c[0].type == 'name' and c[0].value == 'sys'
|
||||
@@ -133,8 +133,8 @@ def _paths_from_list_modifications(module_path, trailer1, trailer2):
|
||||
""" extract the path from either "sys.path.append" or "sys.path.insert" """
|
||||
# Guarantee that both are trailers, the first one a name and the second one
|
||||
# a function execution with at least one param.
|
||||
if not (tree.is_node(trailer1, 'trailer') and trailer1.children[0] == '.'
|
||||
and tree.is_node(trailer2, 'trailer') and trailer2.children[0] == '('
|
||||
if not (trailer1.type == 'trailer' and trailer1.children[0] == '.'
|
||||
and trailer2.type == 'trailer' and trailer2.children[0] == '('
|
||||
and len(trailer2.children) == 3):
|
||||
return []
|
||||
|
||||
@@ -154,10 +154,10 @@ def _check_module(module_context):
|
||||
def get_sys_path_powers(names):
|
||||
for name in names:
|
||||
power = name.parent.parent
|
||||
if tree.is_node(power, 'power', 'atom_expr'):
|
||||
if power.type in ('power', 'atom_expr'):
|
||||
c = power.children
|
||||
if isinstance(c[0], tree.Name) and c[0].value == 'sys' \
|
||||
and tree.is_node(c[1], 'trailer'):
|
||||
and c[1].type == 'trailer':
|
||||
n = c[1].children[1]
|
||||
if isinstance(n, tree.Name) and n.value == 'path':
|
||||
yield name, power
|
||||
|
||||
Reference in New Issue
Block a user