mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
var_args -> arguments
This commit is contained in:
@@ -158,7 +158,7 @@ class FunctionExecutionFilter(ParserTreeFilter):
|
|||||||
for name in names:
|
for name in names:
|
||||||
param = search_ancestor(name, 'param')
|
param = search_ancestor(name, 'param')
|
||||||
if param:
|
if param:
|
||||||
yield ParamName(self._function_value, name, self.parent_context.var_args)
|
yield ParamName(self._function_value, name, self.parent_context.arguments)
|
||||||
else:
|
else:
|
||||||
yield TreeNameDefinition(self.parent_context, name)
|
yield TreeNameDefinition(self.parent_context, name)
|
||||||
|
|
||||||
|
|||||||
@@ -46,10 +46,6 @@ class ExecutedParamName(ParamName):
|
|||||||
matches, argument_values, annotations, color='BLUE')
|
matches, argument_values, annotations, color='BLUE')
|
||||||
return matches
|
return matches
|
||||||
|
|
||||||
@property
|
|
||||||
def var_args(self):
|
|
||||||
return self.arguments
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<%s: %s>' % (self.__class__.__name__, self.string_name)
|
return '<%s: %s>' % (self.__class__.__name__, self.string_name)
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ def infer_expr_stmt(context, stmt, seek_name=None):
|
|||||||
# necessary.
|
# necessary.
|
||||||
if not allowed and context.get_root_context().is_builtins_module():
|
if not allowed and context.get_root_context().is_builtins_module():
|
||||||
try:
|
try:
|
||||||
instance = context.var_args.instance
|
instance = context.arguments.instance
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -140,27 +140,27 @@ class _ArrayInstance(HelperValueMixin):
|
|||||||
in the wild, it's just used within typeshed as an argument to `__init__`
|
in the wild, it's just used within typeshed as an argument to `__init__`
|
||||||
for set/list and never used in any other place.
|
for set/list and never used in any other place.
|
||||||
"""
|
"""
|
||||||
def __init__(self, instance, var_args):
|
def __init__(self, instance, arguments):
|
||||||
self.instance = instance
|
self.instance = instance
|
||||||
self.var_args = var_args
|
self.arguments = arguments
|
||||||
|
|
||||||
def py__class__(self):
|
def py__class__(self):
|
||||||
tuple_, = self.instance.inference_state.builtins_module.py__getattribute__('tuple')
|
tuple_, = self.instance.inference_state.builtins_module.py__getattribute__('tuple')
|
||||||
return tuple_
|
return tuple_
|
||||||
|
|
||||||
def py__iter__(self, contextualized_node=None):
|
def py__iter__(self, contextualized_node=None):
|
||||||
var_args = self.var_args
|
arguments = self.arguments
|
||||||
try:
|
try:
|
||||||
_, lazy_value = next(var_args.unpack())
|
_, lazy_value = next(arguments.unpack())
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for lazy in lazy_value.infer().iterate():
|
for lazy in lazy_value.infer().iterate():
|
||||||
yield lazy
|
yield lazy
|
||||||
|
|
||||||
from jedi.inference import arguments
|
from jedi.inference.arguments import TreeArguments
|
||||||
if isinstance(var_args, arguments.TreeArguments):
|
if isinstance(arguments, TreeArguments):
|
||||||
additions = _internal_check_array_additions(var_args.context, self.instance)
|
additions = _internal_check_array_additions(arguments.context, self.instance)
|
||||||
for addition in additions:
|
for addition in additions:
|
||||||
yield addition
|
yield addition
|
||||||
|
|
||||||
|
|||||||
@@ -162,10 +162,10 @@ class MethodValue(FunctionValue):
|
|||||||
class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
||||||
function_execution_filter = FunctionExecutionFilter
|
function_execution_filter = FunctionExecutionFilter
|
||||||
|
|
||||||
def __init__(self, function_value, var_args):
|
def __init__(self, function_value, arguments):
|
||||||
super(FunctionExecutionContext, self).__init__(function_value)
|
super(FunctionExecutionContext, self).__init__(function_value)
|
||||||
self.function_value = function_value
|
self.function_value = function_value
|
||||||
self.var_args = var_args
|
self.arguments = arguments
|
||||||
|
|
||||||
@inference_state_method_cache(default=NO_VALUES)
|
@inference_state_method_cache(default=NO_VALUES)
|
||||||
@recursion.execution_recursion_decorator()
|
@recursion.execution_recursion_decorator()
|
||||||
@@ -285,7 +285,7 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin):
|
|||||||
self, self._value, until_position=until_position, origin_scope=origin_scope)
|
self, self._value, until_position=until_position, origin_scope=origin_scope)
|
||||||
|
|
||||||
def get_executed_param_names_and_issues(self):
|
def get_executed_param_names_and_issues(self):
|
||||||
return self.var_args.get_executed_param_names_and_issues(self._value)
|
return self.arguments.get_executed_param_names_and_issues(self._value)
|
||||||
|
|
||||||
def infer(self):
|
def infer(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -62,12 +62,12 @@ class AnonymousInstanceArguments(AnonymousArguments):
|
|||||||
class AbstractInstanceValue(Value):
|
class AbstractInstanceValue(Value):
|
||||||
api_type = u'instance'
|
api_type = u'instance'
|
||||||
|
|
||||||
def __init__(self, inference_state, parent_context, class_value, var_args):
|
def __init__(self, inference_state, parent_context, class_value, arguments):
|
||||||
super(AbstractInstanceValue, self).__init__(inference_state, parent_context)
|
super(AbstractInstanceValue, self).__init__(inference_state, parent_context)
|
||||||
# Generated instances are classes that are just generated by self
|
# Generated instances are classes that are just generated by self
|
||||||
# (No var_args) used.
|
# (No arguments) used.
|
||||||
self.class_value = class_value
|
self.class_value = class_value
|
||||||
self.var_args = var_args
|
self.arguments = arguments
|
||||||
|
|
||||||
def is_instance(self):
|
def is_instance(self):
|
||||||
return True
|
return True
|
||||||
@@ -197,7 +197,7 @@ class AbstractInstanceValue(Value):
|
|||||||
)
|
)
|
||||||
bound_method = BoundMethod(self, function)
|
bound_method = BoundMethod(self, function)
|
||||||
|
|
||||||
yield bound_method.as_context(self.var_args)
|
yield bound_method.as_context(self.arguments)
|
||||||
|
|
||||||
@inference_state_method_cache()
|
@inference_state_method_cache()
|
||||||
def create_instance_context(self, class_context, node):
|
def create_instance_context(self, class_context, node):
|
||||||
@@ -215,7 +215,7 @@ class AbstractInstanceValue(Value):
|
|||||||
)
|
)
|
||||||
bound_method = BoundMethod(self, func)
|
bound_method = BoundMethod(self, func)
|
||||||
if scope.name.value == '__init__' and parent_context == class_context:
|
if scope.name.value == '__init__' and parent_context == class_context:
|
||||||
return bound_method.as_context(self.var_args)
|
return bound_method.as_context(self.arguments)
|
||||||
else:
|
else:
|
||||||
return bound_method.as_context()
|
return bound_method.as_context()
|
||||||
elif scope.type == 'classdef':
|
elif scope.type == 'classdef':
|
||||||
@@ -234,20 +234,21 @@ class AbstractInstanceValue(Value):
|
|||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s of %s(%s)>" % (self.__class__.__name__, self.class_value,
|
return "<%s of %s(%s)>" % (self.__class__.__name__, self.class_value,
|
||||||
self.var_args)
|
self.arguments)
|
||||||
|
|
||||||
|
|
||||||
class CompiledInstance(AbstractInstanceValue):
|
class CompiledInstance(AbstractInstanceValue):
|
||||||
def __init__(self, inference_state, parent_context, class_value, var_args):
|
def __init__(self, inference_state, parent_context, class_value, arguments):
|
||||||
self._original_var_args = var_args
|
self._original_arguments = arguments
|
||||||
super(CompiledInstance, self).__init__(inference_state, parent_context, class_value, var_args)
|
super(CompiledInstance, self).__init__(inference_state, parent_context,
|
||||||
|
class_value, arguments)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
return compiled.CompiledValueName(self, self.class_value.name.string_name)
|
return compiled.CompiledValueName(self, self.class_value.name.string_name)
|
||||||
|
|
||||||
def get_first_non_keyword_argument_values(self):
|
def get_first_non_keyword_argument_values(self):
|
||||||
key, lazy_value = next(self._original_var_args.unpack(), ('', None))
|
key, lazy_value = next(self._original_arguments.unpack(), ('', None))
|
||||||
if key is not None:
|
if key is not None:
|
||||||
return NO_VALUES
|
return NO_VALUES
|
||||||
|
|
||||||
@@ -258,17 +259,17 @@ class CompiledInstance(AbstractInstanceValue):
|
|||||||
|
|
||||||
|
|
||||||
class TreeInstance(AbstractInstanceValue):
|
class TreeInstance(AbstractInstanceValue):
|
||||||
def __init__(self, inference_state, parent_context, class_value, var_args):
|
def __init__(self, inference_state, parent_context, class_value, arguments):
|
||||||
# I don't think that dynamic append lookups should happen here. That
|
# I don't think that dynamic append lookups should happen here. That
|
||||||
# sounds more like something that should go to py__iter__.
|
# sounds more like something that should go to py__iter__.
|
||||||
if class_value.py__name__() in ['list', 'set'] \
|
if class_value.py__name__() in ['list', 'set'] \
|
||||||
and parent_context.get_root_context().is_builtins_module():
|
and parent_context.get_root_context().is_builtins_module():
|
||||||
# compare the module path with the builtin name.
|
# compare the module path with the builtin name.
|
||||||
if settings.dynamic_array_additions:
|
if settings.dynamic_array_additions:
|
||||||
var_args = get_dynamic_array_instance(self, var_args)
|
arguments = get_dynamic_array_instance(self, arguments)
|
||||||
|
|
||||||
super(TreeInstance, self).__init__(inference_state, parent_context,
|
super(TreeInstance, self).__init__(inference_state, parent_context,
|
||||||
class_value, var_args)
|
class_value, arguments)
|
||||||
self.tree_node = class_value.tree_node
|
self.tree_node = class_value.tree_node
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -290,7 +291,7 @@ class TreeInstance(AbstractInstanceValue):
|
|||||||
from jedi.inference.gradual.annotation import py__annotations__, \
|
from jedi.inference.gradual.annotation import py__annotations__, \
|
||||||
infer_type_vars_for_execution
|
infer_type_vars_for_execution
|
||||||
|
|
||||||
args = InstanceArguments(self, self.var_args)
|
args = InstanceArguments(self, self.arguments)
|
||||||
for signature in self.class_value.py__getattribute__('__init__').get_signatures():
|
for signature in self.class_value.py__getattribute__('__init__').get_signatures():
|
||||||
# Just take the first result, it should always be one, because we
|
# Just take the first result, it should always be one, because we
|
||||||
# control the typeshed code.
|
# control the typeshed code.
|
||||||
@@ -299,7 +300,7 @@ class TreeInstance(AbstractInstanceValue):
|
|||||||
# need to infer anything.
|
# need to infer anything.
|
||||||
continue
|
continue
|
||||||
bound_method = BoundMethod(self, signature.value)
|
bound_method = BoundMethod(self, signature.value)
|
||||||
execution = bound_method.as_context(self.var_args)
|
execution = bound_method.as_context(self.arguments)
|
||||||
all_annotations = py__annotations__(execution.tree_node)
|
all_annotations = py__annotations__(execution.tree_node)
|
||||||
type_var_dict = infer_type_vars_for_execution(execution, all_annotations)
|
type_var_dict = infer_type_vars_for_execution(execution, all_annotations)
|
||||||
if type_var_dict:
|
if type_var_dict:
|
||||||
@@ -352,7 +353,7 @@ class TreeInstance(AbstractInstanceValue):
|
|||||||
# TODO tuple initializations
|
# TODO tuple initializations
|
||||||
# >>> dict([('a', 4)])
|
# >>> dict([('a', 4)])
|
||||||
# {'a': 4}
|
# {'a': 4}
|
||||||
for key, lazy_context in reversed(list(self.var_args.unpack())):
|
for key, lazy_context in reversed(list(self.arguments.unpack())):
|
||||||
if key is None:
|
if key is None:
|
||||||
values = ValueSet.from_sets(
|
values = ValueSet.from_sets(
|
||||||
dct_value.py__simple_getitem__(index)
|
dct_value.py__simple_getitem__(index)
|
||||||
@@ -373,7 +374,7 @@ class AnonymousInstance(TreeInstance):
|
|||||||
inference_state,
|
inference_state,
|
||||||
parent_context,
|
parent_context,
|
||||||
class_value,
|
class_value,
|
||||||
var_args=AnonymousInstanceArguments(self),
|
arguments=AnonymousInstanceArguments(self),
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_annotated_class_object(self):
|
def get_annotated_class_object(self):
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ def argument_clinic(string, want_obj=False, want_context=False,
|
|||||||
|
|
||||||
@argument_clinic('obj, type, /', want_obj=True, want_arguments=True)
|
@argument_clinic('obj, type, /', want_obj=True, want_arguments=True)
|
||||||
def builtins_property(objects, types, obj, arguments):
|
def builtins_property(objects, types, obj, arguments):
|
||||||
property_args = obj.instance.var_args.unpack()
|
property_args = obj.instance.arguments.unpack()
|
||||||
key, lazy_value = next(property_args, (None, None))
|
key, lazy_value = next(property_args, (None, None))
|
||||||
if key is not None or lazy_value is None:
|
if key is not None or lazy_value is None:
|
||||||
debug.warning('property expected a first param, not %s', arguments)
|
debug.warning('property expected a first param, not %s', arguments)
|
||||||
@@ -270,8 +270,8 @@ class SuperInstance(LazyValueWrapper):
|
|||||||
@argument_clinic('[type[, obj]], /', want_context=True)
|
@argument_clinic('[type[, obj]], /', want_context=True)
|
||||||
def builtins_super(types, objects, context):
|
def builtins_super(types, objects, context):
|
||||||
if isinstance(context, FunctionExecutionContext):
|
if isinstance(context, FunctionExecutionContext):
|
||||||
if isinstance(context.var_args, InstanceArguments):
|
if isinstance(context.arguments, InstanceArguments):
|
||||||
instance = context.var_args.instance
|
instance = context.arguments.instance
|
||||||
# TODO if a class is given it doesn't have to be the direct super
|
# TODO if a class is given it doesn't have to be the direct super
|
||||||
# class, it can be an anecestor from long ago.
|
# class, it can be an anecestor from long ago.
|
||||||
return ValueSet({SuperInstance(instance.inference_state, instance)})
|
return ValueSet({SuperInstance(instance.inference_state, instance)})
|
||||||
|
|||||||
Reference in New Issue
Block a user