mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-18 01:45:02 +08:00
Only 125 fails left in the integration tests.
This commit is contained in:
@@ -484,8 +484,7 @@ class Evaluator(object):
|
||||
))
|
||||
|
||||
if tree.is_node(par, 'trailer') and par.children[0] == '.':
|
||||
call = helpers.call_of_leaf(name, cut_own_trailer=True)
|
||||
values = self.eval_element(context, call)
|
||||
values = helpers.evaluate_call_of_leaf(context, name, cut_own_trailer=True)
|
||||
return unite(
|
||||
self.find_types(value, name, is_goto=True) for value in values
|
||||
)
|
||||
|
||||
@@ -47,6 +47,10 @@ class Context(object):
|
||||
def eval_trailer(self, types, trailer):
|
||||
return self.evaluator.eval_trailer(self, types, trailer)
|
||||
|
||||
def py__getattribute__(self, name_or_str, position=None,
|
||||
search_global=False, is_goto=False):
|
||||
return self.evaluator.find_types(self, name_or_str, position, search_global, is_goto)
|
||||
|
||||
|
||||
class TreeContext(Context):
|
||||
def __init__(self, evaluator, parent_context=None):
|
||||
@@ -62,10 +66,10 @@ class FlowContext(TreeContext):
|
||||
|
||||
class AbstractLazyContext(object):
|
||||
def __init__(self, data):
|
||||
self._data = data
|
||||
self.data = data
|
||||
|
||||
def __repr__(self):
|
||||
return '<%s: %s>' % (self.__class__.__name__, self._data)
|
||||
return '<%s: %s>' % (self.__class__.__name__, self.data)
|
||||
|
||||
def infer(self):
|
||||
raise NotImplementedError
|
||||
@@ -74,13 +78,13 @@ class AbstractLazyContext(object):
|
||||
class LazyKnownContext(AbstractLazyContext):
|
||||
"""data is a context."""
|
||||
def infer(self):
|
||||
yield self._data
|
||||
yield self.data
|
||||
|
||||
|
||||
class LazyKnownContexts(AbstractLazyContext):
|
||||
"""data is a set of contexts."""
|
||||
def infer(self):
|
||||
return self._data
|
||||
return self.data
|
||||
|
||||
|
||||
class LazyUnknownContext(AbstractLazyContext):
|
||||
@@ -97,7 +101,7 @@ class LazyTreeContext(AbstractLazyContext):
|
||||
self._context = context
|
||||
|
||||
def infer(self):
|
||||
return self._context.eval_node(self._data)
|
||||
return self._context.eval_node(self.data)
|
||||
|
||||
|
||||
def get_merged_lazy_context(lazy_contexts):
|
||||
@@ -110,4 +114,4 @@ def get_merged_lazy_context(lazy_contexts):
|
||||
class MergedLazyContexts(AbstractLazyContext):
|
||||
"""data is a list of lazy contexts."""
|
||||
def infer(self):
|
||||
return unite(l.infer() for l in self._data)
|
||||
return unite(l.infer() for l in self.data)
|
||||
|
||||
@@ -16,7 +16,8 @@ from jedi._compatibility import unicode
|
||||
from jedi.common import unite
|
||||
from jedi.evaluate import compiled
|
||||
from jedi.evaluate import representation as er
|
||||
from jedi.evaluate.instance import InstanceFunctionExecution, AbstractInstanceContext
|
||||
from jedi.evaluate.instance import InstanceFunctionExecution, \
|
||||
AbstractInstanceContext, CompiledInstance
|
||||
from jedi.evaluate import iterable
|
||||
from jedi.parser import ParserWithRecovery
|
||||
from jedi import debug
|
||||
@@ -148,18 +149,17 @@ def builtins_reversed(evaluator, sequences, obj, arguments):
|
||||
# While we could do without this variable (just by using sequences), we
|
||||
# want static analysis to work well. Therefore we need to generated the
|
||||
# values again.
|
||||
first_arg = next(arguments.as_tuple())[0]
|
||||
ordered = list(iterable.py__iter__(evaluator, sequences, first_arg))
|
||||
key, lazy_context = next(arguments.unpack())
|
||||
ordered = list(iterable.py__iter__(evaluator, sequences, lazy_context.data))
|
||||
|
||||
rev = [iterable.AlreadyEvaluated(o) for o in reversed(ordered)]
|
||||
rev = list(reversed(ordered))
|
||||
# Repack iterator values and then run it the normal way. This is
|
||||
# necessary, because `reversed` is a function and autocompletion
|
||||
# would fail in certain cases like `reversed(x).__iter__` if we
|
||||
# just returned the result directly.
|
||||
rev = iterable.AlreadyEvaluated(
|
||||
[iterable.FakeSequence(evaluator, rev, 'list')]
|
||||
)
|
||||
return set([er.Instance(evaluator, obj, param.Arguments(evaluator, [rev]))])
|
||||
seq = iterable.FakeSequence(evaluator, 'list', rev)
|
||||
arguments = param.ValuesArguments([[seq]])
|
||||
return set([CompiledInstance(evaluator, evaluator.BUILTINS, obj, arguments)])
|
||||
|
||||
|
||||
@argument_clinic('obj, type, /', want_arguments=True)
|
||||
|
||||
Reference in New Issue
Block a user