1
0
forked from VimPlug/jedi

combine power-or-atom_expr statements into one statement

This commit is contained in:
Claude
2016-02-15 10:20:25 +01:00
parent d5f08f8bdd
commit ca08b8270b
6 changed files with 6 additions and 7 deletions

View File

@@ -291,7 +291,7 @@ class Evaluator(object):
types = set([element]) # TODO this is no real evaluation.
elif element.type == 'expr_stmt':
types = self.eval_statement(element)
elif element.type == 'power' or element.type == 'atom_expr':
elif element.type in ('power', 'atom_expr'):
types = self._eval_atom(element.children[0])
for trailer in element.children[1:]:
if trailer == '**': # has a power operation.

View File

@@ -174,7 +174,7 @@ def _check_for_exception_catch(evaluator, jedi_obj, exception, payload=None):
def check_hasattr(node, suite):
try:
assert suite.start_pos <= jedi_obj.start_pos < suite.end_pos
assert node.type == 'power' or node.type == 'atom_expr'
assert node.type in ('power', 'atom_expr')
base = node.children[0]
assert base.type == 'name' and base.value == 'hasattr'
trailer = node.children[1]

View File

@@ -89,8 +89,7 @@ def search_function_call(evaluator, func):
parent = parent.parent
trailer = None
if tree.is_node(parent, 'power') or \
tree.is_node(parent, 'atom_expr'):
if tree.is_node(parent, 'power', 'atom_expr'):
for t in parent.children[1:]:
if t == '**':
break

View File

@@ -448,7 +448,7 @@ def check_flow_information(evaluator, flow, search_name, pos):
def _check_isinstance_type(evaluator, element, search_name):
try:
assert element.type == 'power' or element.type == 'atom_expr'
assert element.type in ('power', 'atom_expr')
# this might be removed if we analyze and, etc
assert len(element.children) == 2
first, trailer = element.children

View File

@@ -88,7 +88,7 @@ def call_of_name(name, cut_own_trailer=False):
return name
power = par.parent
if (tree.is_node(power, 'power') or tree.is_node(power, 'atom_expr')) \
if tree.is_node(power, 'power', 'atom_expr') \
and power.children[0] != name \
and not (power.children[-2] == '**' and
name.start_pos > power.children[-1].start_pos):

View File

@@ -1342,7 +1342,7 @@ def _defined_names(current):
names += _defined_names(child)
elif is_node(current, 'atom'):
names += _defined_names(current.children[1])
elif is_node(current, 'power') or is_node(current, 'atom_expr'):
elif is_node(current, 'power', 'atom_expr'):
if current.children[-2] != '**': # Just if there's no operation
trailer = current.children[-1]
if trailer.children[0] == '.':