diff --git a/jedi/inference/filters.py b/jedi/inference/filters.py index 3d1c25fd..0e5ec307 100644 --- a/jedi/inference/filters.py +++ b/jedi/inference/filters.py @@ -158,7 +158,7 @@ class FunctionExecutionFilter(ParserTreeFilter): for name in names: param = search_ancestor(name, '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: yield TreeNameDefinition(self.parent_context, name) diff --git a/jedi/inference/param.py b/jedi/inference/param.py index 9c1c3f88..3a8a3b5b 100644 --- a/jedi/inference/param.py +++ b/jedi/inference/param.py @@ -46,10 +46,6 @@ class ExecutedParamName(ParamName): matches, argument_values, annotations, color='BLUE') return matches - @property - def var_args(self): - return self.arguments - def __repr__(self): return '<%s: %s>' % (self.__class__.__name__, self.string_name) diff --git a/jedi/inference/syntax_tree.py b/jedi/inference/syntax_tree.py index 52bf582b..b4e0820b 100644 --- a/jedi/inference/syntax_tree.py +++ b/jedi/inference/syntax_tree.py @@ -270,7 +270,7 @@ def infer_expr_stmt(context, stmt, seek_name=None): # necessary. if not allowed and context.get_root_context().is_builtins_module(): try: - instance = context.var_args.instance + instance = context.arguments.instance except AttributeError: pass else: diff --git a/jedi/inference/value/dynamic_arrays.py b/jedi/inference/value/dynamic_arrays.py index f259821a..bebd802d 100644 --- a/jedi/inference/value/dynamic_arrays.py +++ b/jedi/inference/value/dynamic_arrays.py @@ -140,27 +140,27 @@ class _ArrayInstance(HelperValueMixin): in the wild, it's just used within typeshed as an argument to `__init__` 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.var_args = var_args + self.arguments = arguments def py__class__(self): tuple_, = self.instance.inference_state.builtins_module.py__getattribute__('tuple') return tuple_ def py__iter__(self, contextualized_node=None): - var_args = self.var_args + arguments = self.arguments try: - _, lazy_value = next(var_args.unpack()) + _, lazy_value = next(arguments.unpack()) except StopIteration: pass else: for lazy in lazy_value.infer().iterate(): yield lazy - from jedi.inference import arguments - if isinstance(var_args, arguments.TreeArguments): - additions = _internal_check_array_additions(var_args.context, self.instance) + from jedi.inference.arguments import TreeArguments + if isinstance(arguments, TreeArguments): + additions = _internal_check_array_additions(arguments.context, self.instance) for addition in additions: yield addition diff --git a/jedi/inference/value/function.py b/jedi/inference/value/function.py index 27a3eb4f..0bf6f679 100644 --- a/jedi/inference/value/function.py +++ b/jedi/inference/value/function.py @@ -162,10 +162,10 @@ class MethodValue(FunctionValue): class FunctionExecutionContext(ValueContext, TreeContextMixin): function_execution_filter = FunctionExecutionFilter - def __init__(self, function_value, var_args): + def __init__(self, function_value, arguments): super(FunctionExecutionContext, self).__init__(function_value) self.function_value = function_value - self.var_args = var_args + self.arguments = arguments @inference_state_method_cache(default=NO_VALUES) @recursion.execution_recursion_decorator() @@ -285,7 +285,7 @@ class FunctionExecutionContext(ValueContext, TreeContextMixin): self, self._value, until_position=until_position, origin_scope=origin_scope) 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): """ diff --git a/jedi/inference/value/instance.py b/jedi/inference/value/instance.py index fedb45ef..ccc6095e 100644 --- a/jedi/inference/value/instance.py +++ b/jedi/inference/value/instance.py @@ -62,12 +62,12 @@ class AnonymousInstanceArguments(AnonymousArguments): class AbstractInstanceValue(Value): 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) # Generated instances are classes that are just generated by self - # (No var_args) used. + # (No arguments) used. self.class_value = class_value - self.var_args = var_args + self.arguments = arguments def is_instance(self): return True @@ -197,7 +197,7 @@ class AbstractInstanceValue(Value): ) bound_method = BoundMethod(self, function) - yield bound_method.as_context(self.var_args) + yield bound_method.as_context(self.arguments) @inference_state_method_cache() def create_instance_context(self, class_context, node): @@ -215,7 +215,7 @@ class AbstractInstanceValue(Value): ) bound_method = BoundMethod(self, func) 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: return bound_method.as_context() elif scope.type == 'classdef': @@ -234,20 +234,21 @@ class AbstractInstanceValue(Value): def __repr__(self): return "<%s of %s(%s)>" % (self.__class__.__name__, self.class_value, - self.var_args) + self.arguments) class CompiledInstance(AbstractInstanceValue): - def __init__(self, inference_state, parent_context, class_value, var_args): - self._original_var_args = var_args - super(CompiledInstance, self).__init__(inference_state, parent_context, class_value, var_args) + def __init__(self, inference_state, parent_context, class_value, arguments): + self._original_arguments = arguments + super(CompiledInstance, self).__init__(inference_state, parent_context, + class_value, arguments) @property def name(self): return compiled.CompiledValueName(self, self.class_value.name.string_name) 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: return NO_VALUES @@ -258,17 +259,17 @@ class CompiledInstance(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 # sounds more like something that should go to py__iter__. if class_value.py__name__() in ['list', 'set'] \ and parent_context.get_root_context().is_builtins_module(): # compare the module path with the builtin name. 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, - class_value, var_args) + class_value, arguments) self.tree_node = class_value.tree_node @property @@ -290,7 +291,7 @@ class TreeInstance(AbstractInstanceValue): from jedi.inference.gradual.annotation import py__annotations__, \ 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(): # Just take the first result, it should always be one, because we # control the typeshed code. @@ -299,7 +300,7 @@ class TreeInstance(AbstractInstanceValue): # need to infer anything. continue 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) type_var_dict = infer_type_vars_for_execution(execution, all_annotations) if type_var_dict: @@ -352,7 +353,7 @@ class TreeInstance(AbstractInstanceValue): # TODO tuple initializations # >>> dict([('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: values = ValueSet.from_sets( dct_value.py__simple_getitem__(index) @@ -373,7 +374,7 @@ class AnonymousInstance(TreeInstance): inference_state, parent_context, class_value, - var_args=AnonymousInstanceArguments(self), + arguments=AnonymousInstanceArguments(self), ) def get_annotated_class_object(self): diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index eca602bc..68494234 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -193,7 +193,7 @@ def argument_clinic(string, want_obj=False, want_context=False, @argument_clinic('obj, type, /', want_obj=True, want_arguments=True) 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)) if key is not None or lazy_value is None: debug.warning('property expected a first param, not %s', arguments) @@ -270,8 +270,8 @@ class SuperInstance(LazyValueWrapper): @argument_clinic('[type[, obj]], /', want_context=True) def builtins_super(types, objects, context): if isinstance(context, FunctionExecutionContext): - if isinstance(context.var_args, InstanceArguments): - instance = context.var_args.instance + 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)})