forked from VimPlug/jedi
Use function/arguments intead of execution
This commit is contained in:
@@ -162,7 +162,6 @@ class MethodValue(FunctionValue):
|
||||
class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||
def __init__(self, function_value, arguments):
|
||||
super(FunctionExecutionContext, self).__init__(function_value)
|
||||
self.function_value = function_value
|
||||
self._arguments = arguments
|
||||
|
||||
@inference_state_method_cache(default=NO_VALUES)
|
||||
@@ -178,12 +177,12 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||
else:
|
||||
returns = funcdef.iter_return_stmts()
|
||||
from jedi.inference.gradual.annotation import infer_return_types
|
||||
value_set = infer_return_types(self)
|
||||
value_set = infer_return_types(self._value, self._arguments)
|
||||
if value_set:
|
||||
# If there are annotations, prefer them over anything else.
|
||||
# This will make it faster.
|
||||
return value_set
|
||||
value_set |= docstrings.infer_return_types(self.function_value)
|
||||
value_set |= docstrings.infer_return_types(self._value)
|
||||
|
||||
for r in returns:
|
||||
check = flow_analysis.reachability_check(self, funcdef, r)
|
||||
|
||||
@@ -300,12 +300,11 @@ class TreeInstance(AbstractInstanceValue):
|
||||
# need to infer anything.
|
||||
continue
|
||||
bound_method = BoundMethod(self, signature.value)
|
||||
execution = bound_method.as_context(self.arguments)
|
||||
all_annotations = py__annotations__(execution.tree_node)
|
||||
type_var_dict = infer_type_vars_for_execution(execution, all_annotations)
|
||||
all_annotations = py__annotations__(signature.value.tree_node)
|
||||
type_var_dict = infer_type_vars_for_execution(bound_method, args, all_annotations)
|
||||
if type_var_dict:
|
||||
defined, = self.class_value.define_generics(
|
||||
infer_type_vars_for_execution(execution, all_annotations),
|
||||
infer_type_vars_for_execution(signature.value, args, all_annotations),
|
||||
)
|
||||
debug.dbg('Inferred instance value as %s', defined, color='BLUE')
|
||||
return defined
|
||||
|
||||
Reference in New Issue
Block a user