forked from VimPlug/jedi
Fixed list comprehension name lookups.
This commit is contained in:
@@ -215,6 +215,8 @@ class Evaluator(object):
|
||||
# This is the first global lookup.
|
||||
stmt = atom.get_definition()
|
||||
scope = stmt.get_parent_until(pr.IsScope, include_current=True)
|
||||
if isinstance(stmt, pr.CompFor):
|
||||
stmt = stmt.get_parent_until((pr.ClassOrFunc, pr.ExprStmt))
|
||||
return self.find_types(scope, atom, stmt.start_pos, search_global=True)
|
||||
elif isinstance(atom, pr.Literal):
|
||||
return [compiled.create(self, atom.eval())]
|
||||
|
||||
@@ -151,6 +151,9 @@ class Comprehension(IterableWrapper):
|
||||
|
||||
return helpers.deep_ast_copy(comprehension.children[0], {comprehension: last_comp})
|
||||
|
||||
def get_exact_index_types(self, index):
|
||||
return [self._evaluator.eval_element(self.eval_node())[index]]
|
||||
|
||||
def __repr__(self):
|
||||
return "<e%s of %s>" % (type(self).__name__, self._atom)
|
||||
|
||||
|
||||
@@ -88,14 +88,8 @@ class _RecursionNode(object):
|
||||
if not other:
|
||||
return None
|
||||
|
||||
# List Comprehensions start on the same line as its statement.
|
||||
# Therefore we have the unfortunate situation of the same start_pos for
|
||||
# two statements.
|
||||
is_list_comp = lambda x: isinstance(x, pr.ListComprehension)
|
||||
return self.script == other.script \
|
||||
and self.position == other.position \
|
||||
and not is_list_comp(self.stmt.parent) \
|
||||
and not is_list_comp(other.parent) \
|
||||
and not self.is_ignored and not other.is_ignored
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user