mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 05:54:25 +08:00
Make FunctionExecutionContext.arguments private
This commit is contained in:
@@ -143,22 +143,22 @@ class ParserTreeFilter(AbstractUsedNamesFilter):
|
||||
|
||||
|
||||
class FunctionExecutionFilter(ParserTreeFilter):
|
||||
def __init__(self, parent_context, function_value, node_context=None,
|
||||
until_position=None, origin_scope=None):
|
||||
def __init__(self, parent_context, function_value,
|
||||
until_position, origin_scope, arguments):
|
||||
super(FunctionExecutionFilter, self).__init__(
|
||||
parent_context,
|
||||
node_context,
|
||||
until_position,
|
||||
origin_scope
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope,
|
||||
)
|
||||
self._function_value = function_value
|
||||
self._arguments = arguments
|
||||
|
||||
@to_list
|
||||
def _convert_names(self, names):
|
||||
for name in names:
|
||||
param = search_ancestor(name, 'param')
|
||||
if param:
|
||||
yield ParamName(self._function_value, name, self.parent_context.arguments)
|
||||
yield ParamName(self._function_value, name, self._arguments)
|
||||
else:
|
||||
yield TreeNameDefinition(self.parent_context, name)
|
||||
|
||||
|
||||
@@ -160,12 +160,10 @@ class MethodValue(FunctionValue):
|
||||
|
||||
|
||||
class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||
function_execution_filter = FunctionExecutionFilter
|
||||
|
||||
def __init__(self, function_value, arguments):
|
||||
super(FunctionExecutionContext, self).__init__(function_value)
|
||||
self.function_value = function_value
|
||||
self.arguments = arguments
|
||||
self._arguments = arguments
|
||||
|
||||
@inference_state_method_cache(default=NO_VALUES)
|
||||
@recursion.execution_recursion_decorator()
|
||||
@@ -282,10 +280,14 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||
|
||||
def get_filters(self, until_position=None, origin_scope=None):
|
||||
yield FunctionExecutionFilter(
|
||||
self, self._value, until_position=until_position, origin_scope=origin_scope)
|
||||
self, self._value,
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope,
|
||||
arguments=self._arguments
|
||||
)
|
||||
|
||||
def get_executed_param_names_and_issues(self):
|
||||
return self.arguments.get_executed_param_names_and_issues(self._value)
|
||||
return self._arguments.get_executed_param_names_and_issues(self._value)
|
||||
|
||||
def infer(self):
|
||||
"""
|
||||
|
||||
@@ -270,8 +270,9 @@ class SuperInstance(LazyValueWrapper):
|
||||
@argument_clinic('[type[, obj]], /', want_context=True)
|
||||
def builtins_super(types, objects, context):
|
||||
if isinstance(context, FunctionExecutionContext):
|
||||
if isinstance(context.arguments, InstanceArguments):
|
||||
instance = context.arguments.instance
|
||||
# TODO _arguments should be private. make this different.
|
||||
if isinstance(context._arguments, InstanceArguments):
|
||||
instance = context._arguments.instance
|
||||
# TODO if a class is given it doesn't have to be the direct super
|
||||
# class, it can be an anecestor from long ago.
|
||||
return ValueSet({SuperInstance(instance.inference_state, instance)})
|
||||
|
||||
Reference in New Issue
Block a user