mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-09 13:32:20 +08:00
Fix an array lookup issue. list.pop calls work now pretty well and return the right type.
This commit is contained in:
@@ -146,7 +146,7 @@ class Evaluator(object):
|
|||||||
@memoize_default(evaluator_is_first_arg=True)
|
@memoize_default(evaluator_is_first_arg=True)
|
||||||
def eval_element(self, element):
|
def eval_element(self, element):
|
||||||
if isinstance(element, iterable.AlreadyEvaluated):
|
if isinstance(element, iterable.AlreadyEvaluated):
|
||||||
return element
|
return list(element)
|
||||||
elif isinstance(element, iterable.MergedNodes):
|
elif isinstance(element, iterable.MergedNodes):
|
||||||
return iterable.unite(self.eval_element(e) for e in element)
|
return iterable.unite(self.eval_element(e) for e in element)
|
||||||
|
|
||||||
|
|||||||
@@ -246,7 +246,8 @@ class Array(IterableWrapper):
|
|||||||
def names_dicts(self, search_global=False): # Always False.
|
def names_dicts(self, search_global=False): # Always False.
|
||||||
# `array.type` is a string with the type, e.g. 'list'.
|
# `array.type` is a string with the type, e.g. 'list'.
|
||||||
scope = self._evaluator.find_types(compiled.builtin, self.type)[0]
|
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)
|
return scope.names_dicts(search_global)
|
||||||
|
|
||||||
@common.safe_property
|
@common.safe_property
|
||||||
|
|||||||
@@ -44,7 +44,18 @@ class Arguments(pr.Base):
|
|||||||
yield 0, child
|
yield 0, child
|
||||||
|
|
||||||
def get_parent_until(self, *args, **kwargs):
|
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):
|
def as_tuple(self):
|
||||||
for stars, argument in self._split():
|
for stars, argument in self._split():
|
||||||
|
|||||||
@@ -47,6 +47,17 @@ arr2.app
|
|||||||
#? int()
|
#? int()
|
||||||
arr.count(1)
|
arr.count(1)
|
||||||
|
|
||||||
|
x = []
|
||||||
|
#?
|
||||||
|
x.pop()
|
||||||
|
x = [3]
|
||||||
|
#? int()
|
||||||
|
x.pop()
|
||||||
|
x = []
|
||||||
|
x.append(1.0)
|
||||||
|
#? float()
|
||||||
|
x.pop()
|
||||||
|
|
||||||
# -----------------
|
# -----------------
|
||||||
# dicts
|
# dicts
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|||||||
Reference in New Issue
Block a user