execute_evaluated -> execute_with_values

This commit is contained in:
Dave Halter
2019-08-13 01:29:50 +02:00
parent 084995c378
commit 467839a9ea
14 changed files with 33 additions and 33 deletions
+8 -8
View File
@@ -38,13 +38,13 @@ class HelperContextMixin(object):
def execute(self, arguments):
return self.evaluator.execute(self, arguments=arguments)
def execute_evaluated(self, *value_list):
def execute_with_values(self, *value_list):
from jedi.evaluate.arguments import ValuesArguments
arguments = ValuesArguments([ContextSet([value]) for value in value_list])
return self.evaluator.execute(self, arguments)
def execute_annotation(self):
return self.execute_evaluated()
return self.execute_with_values()
def gather_annotation_classes(self):
return ContextSet([self])
@@ -75,7 +75,7 @@ class HelperContextMixin(object):
await_context_set = self.py__getattribute__(u"__await__")
if not await_context_set:
debug.warning('Tried to run __await__ on context %s', self)
return await_context_set.execute_evaluated()
return await_context_set.execute_with_values()
def eval_node(self, node):
return self.evaluator.eval_element(self, node)
@@ -91,9 +91,9 @@ class HelperContextMixin(object):
# TypeError: 'async for' requires an object with __aiter__ method, got int
return iter([
LazyKnownContexts(
self.py__getattribute__('__aiter__').execute_evaluated()
.py__getattribute__('__anext__').execute_evaluated()
.py__getattribute__('__await__').execute_evaluated()
self.py__getattribute__('__aiter__').execute_with_values()
.py__getattribute__('__anext__').execute_with_values()
.py__getattribute__('__await__').execute_with_values()
.py__stop_iteration_returns()
) # noqa
])
@@ -397,8 +397,8 @@ class ContextSet(BaseContextSet):
def execute(self, arguments):
return ContextSet.from_sets(c.evaluator.execute(c, arguments) for c in self._set)
def execute_evaluated(self, *args, **kwargs):
return ContextSet.from_sets(c.execute_evaluated(*args, **kwargs) for c in self._set)
def execute_with_values(self, *args, **kwargs):
return ContextSet.from_sets(c.execute_with_values(*args, **kwargs) for c in self._set)
def py__getattribute__(self, *args, **kwargs):
if kwargs.get('is_goto'):
+2 -2
View File
@@ -29,7 +29,7 @@ class CompiledValue(LazyContextWrapper):
def _get_wrapped_context(self):
instance, = builtin_from_name(
self.evaluator, self._compiled_obj.name.string_name).execute_evaluated()
self.evaluator, self._compiled_obj.name.string_name).execute_with_values()
return instance
def __repr__(self):
@@ -50,7 +50,7 @@ def create_simple_object(evaluator, obj):
def get_string_context_set(evaluator):
return builtin_from_name(evaluator, u'str').execute_evaluated()
return builtin_from_name(evaluator, u'str').execute_with_values()
def load_module(evaluator, dotted_name, **kwargs):
+1 -1
View File
@@ -328,7 +328,7 @@ class SignatureParamName(ParamNameInterface, AbstractNameDefinition):
contexts = ContextSet([create_from_access_path(evaluator, p.default)])
if p.has_annotation:
annotation = create_from_access_path(evaluator, p.annotation)
contexts |= annotation.execute_evaluated()
contexts |= annotation.execute_with_values()
return contexts
+1 -1
View File
@@ -283,7 +283,7 @@ def _create(evaluator, access_handle, parent_context, *args):
if tree_node.type == 'classdef':
if not access_handle.is_class():
# Is an instance, not a class.
tree_contexts = tree_contexts.execute_evaluated()
tree_contexts = tree_contexts.execute_with_values()
return ContextSet(
MixedObject(compiled_object, tree_context=tree_context)
+1 -1
View File
@@ -65,7 +65,7 @@ class FunctionMixin(object):
)
else:
cls = self.py__class__()
for instance in cls.execute_evaluated():
for instance in cls.execute_with_values():
for filter in instance.get_filters(search_global=False, origin_scope=origin_scope):
yield filter
+1 -1
View File
@@ -107,7 +107,7 @@ class AbstractInstanceContext(Context):
def execute_function_slots(self, names, *evaluated_args):
return ContextSet.from_sets(
name.infer().execute_evaluated(*evaluated_args)
name.infer().execute_with_values(*evaluated_args)
for name in names
)
+1 -1
View File
@@ -793,7 +793,7 @@ class Slice(object):
def __getattr__(self, name):
if self._slice_object is None:
context = compiled.builtin_from_name(self._context.evaluator, 'slice')
self._slice_object, = context.execute_evaluated()
self._slice_object, = context.execute_with_values()
return getattr(self._slice_object, name)
@property
+2 -2
View File
@@ -284,7 +284,7 @@ def _check_isinstance_type(context, element, search_name):
for cls_or_tup in lazy_context_cls.infer():
if isinstance(cls_or_tup, iterable.Sequence) and cls_or_tup.array_type == 'tuple':
for lazy_context in cls_or_tup.py__iter__():
context_set |= lazy_context.infer().execute_evaluated()
context_set |= lazy_context.infer().execute_with_values()
else:
context_set |= cls_or_tup.execute_evaluated()
context_set |= cls_or_tup.execute_with_values()
return context_set
+2 -2
View File
@@ -28,7 +28,7 @@ def _stub_to_python_context_set(stub_context, ignore_compiled=False):
contexts = _infer_from_stub(stub_module, qualified_names, ignore_compiled)
if was_instance:
contexts = ContextSet.from_sets(
c.execute_evaluated()
c.execute_with_values()
for c in contexts
if c.is_class()
)
@@ -188,7 +188,7 @@ def to_stub(context):
if was_instance:
stub_contexts = ContextSet.from_sets(
c.execute_evaluated()
c.execute_with_values()
for c in stub_contexts
if c.is_class()
)
+4 -4
View File
@@ -139,7 +139,7 @@ def eval_node(context, element):
# Implies that it's a yield from.
element = element.children[1].children[1]
generators = context.eval_node(element) \
.py__getattribute__('__iter__').execute_evaluated()
.py__getattribute__('__iter__').execute_with_values()
return generators.py__stop_iteration_returns()
# Generator.send() is not implemented.
@@ -391,7 +391,7 @@ def _literals_to_types(evaluator, result):
# Literals are only valid as long as the operations are
# correct. Otherwise add a value-free instance.
cls = compiled.builtin_from_name(evaluator, typ.name.string_name)
new_result |= cls.execute_evaluated()
new_result |= cls.execute_with_values()
else:
new_result |= ContextSet([typ])
return new_result
@@ -608,7 +608,7 @@ def tree_name_to_contexts(evaluator, context, tree_name):
elif typ == 'with_stmt':
context_managers = context.eval_node(node.get_test_node_from_name(tree_name))
enter_methods = context_managers.py__getattribute__(u'__enter__')
return enter_methods.execute_evaluated()
return enter_methods.execute_with_values()
elif typ in ('import_from', 'import_name'):
types = imports.infer_import(context, tree_name)
elif typ in ('funcdef', 'classdef'):
@@ -618,7 +618,7 @@ def tree_name_to_contexts(evaluator, context, tree_name):
# TODO check for types that are not classes and add it to
# the static analysis report.
exceptions = context.eval_node(tree_name.get_previous_sibling().get_previous_sibling())
types = exceptions.execute_evaluated()
types = exceptions.execute_with_values()
elif node.type == 'param':
types = NO_CONTEXTS
else: