forked from VimPlug/jedi
Deal with inheritance properly when dealing with function executions
This commit is contained in:
@@ -454,14 +454,14 @@ def get_global_filters(context, until_position, origin_scope):
|
||||
[...]
|
||||
"""
|
||||
base_context = context
|
||||
from jedi.inference.value.function import FunctionExecutionContext
|
||||
from jedi.inference.value.function import BaseFunctionExecutionContext
|
||||
while context is not None:
|
||||
# Names in methods cannot be resolved within the class.
|
||||
for filter in context.get_filters(
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope):
|
||||
yield filter
|
||||
if isinstance(context, FunctionExecutionContext):
|
||||
if isinstance(context, BaseFunctionExecutionContext):
|
||||
# The position should be reset if the current scope is a function.
|
||||
until_position = None
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ def _get_potential_nodes(module_value, func_string_name):
|
||||
|
||||
|
||||
def _check_name_for_execution(inference_state, context, compare_node, name, trailer):
|
||||
from jedi.inference.value.function import FunctionExecutionContext
|
||||
from jedi.inference.value.function import BaseFunctionExecutionContext
|
||||
|
||||
def create_func_excs(value):
|
||||
arglist = trailer.children[1]
|
||||
@@ -203,8 +203,8 @@ def _check_name_for_execution(inference_state, context, compare_node, name, trai
|
||||
for func_execution in create_func_excs(value):
|
||||
# TODO private access
|
||||
yield func_execution._arguments
|
||||
elif isinstance(value.parent_context, FunctionExecutionContext) and \
|
||||
compare_node.type == 'funcdef':
|
||||
elif isinstance(value.parent_context, BaseFunctionExecutionContext) \
|
||||
and compare_node.type == 'funcdef':
|
||||
# Here we're trying to find decorators by checking the first
|
||||
# parameter. It's not very generic though. Should find a better
|
||||
# solution that also applies to nested decorators.
|
||||
|
||||
@@ -160,11 +160,7 @@ class MethodValue(FunctionValue):
|
||||
return names + (self.py__name__(),)
|
||||
|
||||
|
||||
class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||
def __init__(self, function_value, arguments):
|
||||
super(FunctionExecutionContext, self).__init__(function_value)
|
||||
self._arguments = arguments
|
||||
|
||||
class BaseFunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||
@inference_state_method_cache(default=NO_VALUES)
|
||||
@recursion.execution_recursion_decorator()
|
||||
def get_return_values(self, check_yields=False):
|
||||
@@ -278,14 +274,6 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||
for lazy_value in self.get_yield_lazy_values()
|
||||
)
|
||||
|
||||
def get_filters(self, until_position=None, origin_scope=None):
|
||||
yield FunctionExecutionFilter(
|
||||
self, self._value,
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope,
|
||||
arguments=self._arguments
|
||||
)
|
||||
|
||||
def infer(self):
|
||||
"""
|
||||
Created to be used by inheritance.
|
||||
@@ -326,6 +314,20 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||
else:
|
||||
return self.get_return_values()
|
||||
|
||||
|
||||
class FunctionExecutionContext(BaseFunctionExecutionContext):
|
||||
def __init__(self, function_value, arguments):
|
||||
super(FunctionExecutionContext, self).__init__(function_value)
|
||||
self._arguments = arguments
|
||||
|
||||
def get_filters(self, until_position=None, origin_scope=None):
|
||||
yield FunctionExecutionFilter(
|
||||
self, self._value,
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope,
|
||||
arguments=self._arguments
|
||||
)
|
||||
|
||||
def get_param_names(self):
|
||||
return [
|
||||
ParamName(self._value, param.name, self._arguments)
|
||||
@@ -333,10 +335,7 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||
]
|
||||
|
||||
|
||||
class AnonymousFunctionExecution(FunctionExecutionContext):
|
||||
def __init__(self, function_value):
|
||||
super(AnonymousFunctionExecution, self).__init__(function_value, arguments=None)
|
||||
|
||||
class AnonymousFunctionExecution(BaseFunctionExecutionContext):
|
||||
def get_filters(self, until_position=None, origin_scope=None):
|
||||
yield FunctionExecutionFilter(
|
||||
self, self._value,
|
||||
|
||||
Reference in New Issue
Block a user