1
0
forked from VimPlug/jedi

var_args -> arguments

This commit is contained in:
Dave Halter
2019-09-02 19:48:17 +02:00
parent e97bb1d2e5
commit 06890203dd
7 changed files with 33 additions and 36 deletions

View File

@@ -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):