1
0
forked from VimPlug/jedi

Fix an array lookup issue. list.pop calls work now pretty well and return the right type.

This commit is contained in:
Dave Halter
2015-02-26 13:57:54 +01:00
parent d318d3c855
commit b8a8c4d402
4 changed files with 26 additions and 3 deletions

View File

@@ -146,7 +146,7 @@ class Evaluator(object):
@memoize_default(evaluator_is_first_arg=True)
def eval_element(self, element):
if isinstance(element, iterable.AlreadyEvaluated):
return element
return list(element)
elif isinstance(element, iterable.MergedNodes):
return iterable.unite(self.eval_element(e) for e in element)

View File

@@ -246,7 +246,8 @@ class Array(IterableWrapper):
def names_dicts(self, search_global=False): # Always False.
# `array.type` is a string with the type, e.g. 'list'.
scope = self._evaluator.find_types(compiled.builtin, self.type)[0]
scope = self._evaluator.execute(scope)[0] # builtins only have one class
# builtins only have one class -> [0]
scope = self._evaluator.execute(scope, (AlreadyEvaluated((self,)),))[0]
return scope.names_dicts(search_global)
@common.safe_property

View File

@@ -44,7 +44,18 @@ class Arguments(pr.Base):
yield 0, child
def get_parent_until(self, *args, **kwargs):
return self.trailer.get_parent_until(*args, **kwargs)
if self.trailer is None:
try:
element = self.argument_node[0]
from jedi.evaluate.iterable import AlreadyEvaluated
if isinstance(element, AlreadyEvaluated):
element = self._evaluator.eval_element(element)[0]
except IndexError:
return None
else:
return element.get_parent_until(*args, **kwargs)
else:
return self.trailer.get_parent_until(*args, **kwargs)
def as_tuple(self):
for stars, argument in self._split():

View File

@@ -47,6 +47,17 @@ arr2.app
#? int()
arr.count(1)
x = []
#?
x.pop()
x = [3]
#? int()
x.pop()
x = []
x.append(1.0)
#? float()
x.pop()
# -----------------
# dicts
# -----------------