forked from VimPlug/jedi
Replace obj with value
This commit is contained in:
@@ -145,7 +145,7 @@ def _follow_param(inference_state, arguments, index):
|
|||||||
return lazy_value.infer()
|
return lazy_value.infer()
|
||||||
|
|
||||||
|
|
||||||
def argument_clinic(string, want_obj=False, want_context=False,
|
def argument_clinic(string, want_value=False, want_context=False,
|
||||||
want_arguments=False, want_inference_state=False,
|
want_arguments=False, want_inference_state=False,
|
||||||
want_callback=False):
|
want_callback=False):
|
||||||
"""
|
"""
|
||||||
@@ -155,18 +155,18 @@ def argument_clinic(string, want_obj=False, want_context=False,
|
|||||||
def f(func):
|
def f(func):
|
||||||
@repack_with_argument_clinic(string, keep_arguments_param=True,
|
@repack_with_argument_clinic(string, keep_arguments_param=True,
|
||||||
keep_callback_param=True)
|
keep_callback_param=True)
|
||||||
def wrapper(obj, *args, **kwargs):
|
def wrapper(value, *args, **kwargs):
|
||||||
arguments = kwargs.pop('arguments')
|
arguments = kwargs.pop('arguments')
|
||||||
callback = kwargs.pop('callback')
|
callback = kwargs.pop('callback')
|
||||||
assert not kwargs # Python 2...
|
assert not kwargs # Python 2...
|
||||||
debug.dbg('builtin start %s' % obj, color='MAGENTA')
|
debug.dbg('builtin start %s' % value, color='MAGENTA')
|
||||||
result = NO_VALUES
|
result = NO_VALUES
|
||||||
if want_context:
|
if want_context:
|
||||||
kwargs['context'] = arguments.context
|
kwargs['context'] = arguments.context
|
||||||
if want_obj:
|
if want_value:
|
||||||
kwargs['obj'] = obj
|
kwargs['value'] = value
|
||||||
if want_inference_state:
|
if want_inference_state:
|
||||||
kwargs['inference_state'] = obj.inference_state
|
kwargs['inference_state'] = value.inference_state
|
||||||
if want_arguments:
|
if want_arguments:
|
||||||
kwargs['arguments'] = arguments
|
kwargs['arguments'] = arguments
|
||||||
if want_callback:
|
if want_callback:
|
||||||
@@ -200,14 +200,14 @@ def builtins_iter(iterators_or_callables, defaults):
|
|||||||
@argument_clinic('object, name[, default], /')
|
@argument_clinic('object, name[, default], /')
|
||||||
def builtins_getattr(objects, names, defaults=None):
|
def builtins_getattr(objects, names, defaults=None):
|
||||||
# follow the first param
|
# follow the first param
|
||||||
for obj in objects:
|
for value in objects:
|
||||||
for name in names:
|
for name in names:
|
||||||
string = get_str_or_none(name)
|
string = get_str_or_none(name)
|
||||||
if string is None:
|
if string is None:
|
||||||
debug.warning('getattr called without str')
|
debug.warning('getattr called without str')
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
return obj.py__getattribute__(force_unicode(string))
|
return value.py__getattribute__(force_unicode(string))
|
||||||
return NO_VALUES
|
return NO_VALUES
|
||||||
|
|
||||||
|
|
||||||
@@ -239,12 +239,12 @@ class SuperInstance(LazyValueWrapper):
|
|||||||
|
|
||||||
def get_filters(self, origin_scope=None):
|
def get_filters(self, origin_scope=None):
|
||||||
for b in self._get_bases():
|
for b in self._get_bases():
|
||||||
for obj in b.infer().execute_with_values():
|
for value in b.infer().execute_with_values():
|
||||||
for f in obj.get_filters():
|
for f in value.get_filters():
|
||||||
yield f
|
yield f
|
||||||
|
|
||||||
|
|
||||||
@argument_clinic('[type[, obj]], /', want_context=True)
|
@argument_clinic('[type[, value]], /', want_context=True)
|
||||||
def builtins_super(types, objects, context):
|
def builtins_super(types, objects, context):
|
||||||
instance = None
|
instance = None
|
||||||
if isinstance(context, AnonymousMethodExecutionContext):
|
if isinstance(context, AnonymousMethodExecutionContext):
|
||||||
@@ -273,8 +273,8 @@ class ReversedObject(AttributeOverwrite):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@argument_clinic('sequence, /', want_obj=True, want_arguments=True)
|
@argument_clinic('sequence, /', want_value=True, want_arguments=True)
|
||||||
def builtins_reversed(sequences, obj, arguments):
|
def builtins_reversed(sequences, value, arguments):
|
||||||
# While we could do without this variable (just by using sequences), we
|
# While we could do without this variable (just by using sequences), we
|
||||||
# want static analysis to work well. Therefore we need to generated the
|
# want static analysis to work well. Therefore we need to generated the
|
||||||
# values again.
|
# values again.
|
||||||
@@ -288,11 +288,11 @@ def builtins_reversed(sequences, obj, arguments):
|
|||||||
# necessary, because `reversed` is a function and autocompletion
|
# necessary, because `reversed` is a function and autocompletion
|
||||||
# would fail in certain cases like `reversed(x).__iter__` if we
|
# would fail in certain cases like `reversed(x).__iter__` if we
|
||||||
# just returned the result directly.
|
# just returned the result directly.
|
||||||
seq, = obj.inference_state.typing_module.py__getattribute__('Iterator').execute_with_values()
|
seq, = value.inference_state.typing_module.py__getattribute__('Iterator').execute_with_values()
|
||||||
return ValueSet([ReversedObject(seq, list(reversed(ordered)))])
|
return ValueSet([ReversedObject(seq, list(reversed(ordered)))])
|
||||||
|
|
||||||
|
|
||||||
@argument_clinic('obj, type, /', want_arguments=True, want_inference_state=True)
|
@argument_clinic('value, type, /', want_arguments=True, want_inference_state=True)
|
||||||
def builtins_isinstance(objects, types, arguments, inference_state):
|
def builtins_isinstance(objects, types, arguments, inference_state):
|
||||||
bool_results = set()
|
bool_results = set()
|
||||||
for o in objects:
|
for o in objects:
|
||||||
@@ -349,7 +349,7 @@ class ClassMethodObject(ValueWrapper):
|
|||||||
super(ClassMethodObject, self).__init__(class_method_obj)
|
super(ClassMethodObject, self).__init__(class_method_obj)
|
||||||
self._function = function
|
self._function = function
|
||||||
|
|
||||||
def py__get__(self, obj, class_value):
|
def py__get__(self, instance, class_value):
|
||||||
return ValueSet([
|
return ValueSet([
|
||||||
ClassMethodGet(__get__, class_value, self._function)
|
ClassMethodGet(__get__, class_value, self._function)
|
||||||
for __get__ in self._wrapped_value.py__getattribute__('__get__')
|
for __get__ in self._wrapped_value.py__getattribute__('__get__')
|
||||||
@@ -380,11 +380,11 @@ class ClassMethodArguments(TreeArgumentsWrapper):
|
|||||||
yield values
|
yield values
|
||||||
|
|
||||||
|
|
||||||
@argument_clinic('sequence, /', want_obj=True, want_arguments=True)
|
@argument_clinic('sequence, /', want_value=True, want_arguments=True)
|
||||||
def builtins_classmethod(functions, obj, arguments):
|
def builtins_classmethod(functions, value, arguments):
|
||||||
return ValueSet(
|
return ValueSet(
|
||||||
ClassMethodObject(class_method_object, function)
|
ClassMethodObject(class_method_object, function)
|
||||||
for class_method_object in obj.py__call__(arguments=arguments)
|
for class_method_object in value.py__call__(arguments=arguments)
|
||||||
for function in functions
|
for function in functions
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -415,7 +415,7 @@ def builtins_property(functions, callback):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def collections_namedtuple(obj, arguments, callback):
|
def collections_namedtuple(value, arguments, callback):
|
||||||
"""
|
"""
|
||||||
Implementation of the namedtuple function.
|
Implementation of the namedtuple function.
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ def collections_namedtuple(obj, arguments, callback):
|
|||||||
inferring the result.
|
inferring the result.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
inference_state = obj.inference_state
|
inference_state = value.inference_state
|
||||||
|
|
||||||
# Process arguments
|
# Process arguments
|
||||||
name = u'jedi_unknown_namedtuple'
|
name = u'jedi_unknown_namedtuple'
|
||||||
@@ -542,10 +542,10 @@ class MergedPartialArguments(AbstractArguments):
|
|||||||
yield key_lazy_value
|
yield key_lazy_value
|
||||||
|
|
||||||
|
|
||||||
def functools_partial(obj, arguments, callback):
|
def functools_partial(value, arguments, callback):
|
||||||
return ValueSet(
|
return ValueSet(
|
||||||
PartialObject(instance, arguments)
|
PartialObject(instance, arguments)
|
||||||
for instance in obj.py__call__(arguments)
|
for instance in value.py__call__(arguments)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -563,12 +563,12 @@ def _random_choice(sequences):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _dataclass(obj, arguments, callback):
|
def _dataclass(value, arguments, callback):
|
||||||
for c in _follow_param(obj.inference_state, arguments, 0):
|
for c in _follow_param(value.inference_state, arguments, 0):
|
||||||
if c.is_class():
|
if c.is_class():
|
||||||
return ValueSet([DataclassWrapper(c)])
|
return ValueSet([DataclassWrapper(c)])
|
||||||
else:
|
else:
|
||||||
return ValueSet([obj])
|
return ValueSet([value])
|
||||||
return NO_VALUES
|
return NO_VALUES
|
||||||
|
|
||||||
|
|
||||||
@@ -674,17 +674,17 @@ class Wrapped(ValueWrapper, FunctionMixin):
|
|||||||
return [self]
|
return [self]
|
||||||
|
|
||||||
|
|
||||||
@argument_clinic('*args, /', want_obj=True, want_arguments=True)
|
@argument_clinic('*args, /', want_value=True, want_arguments=True)
|
||||||
def _operator_itemgetter(args_value_set, obj, arguments):
|
def _operator_itemgetter(args_value_set, value, arguments):
|
||||||
return ValueSet([
|
return ValueSet([
|
||||||
ItemGetterCallable(instance, args_value_set)
|
ItemGetterCallable(instance, args_value_set)
|
||||||
for instance in obj.py__call__(arguments)
|
for instance in value.py__call__(arguments)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
def _create_string_input_function(func):
|
def _create_string_input_function(func):
|
||||||
@argument_clinic('string, /', want_obj=True, want_arguments=True)
|
@argument_clinic('string, /', want_value=True, want_arguments=True)
|
||||||
def wrapper(strings, obj, arguments):
|
def wrapper(strings, value, arguments):
|
||||||
def iterate():
|
def iterate():
|
||||||
for value in strings:
|
for value in strings:
|
||||||
s = get_str_or_none(value)
|
s = get_str_or_none(value)
|
||||||
@@ -694,7 +694,7 @@ def _create_string_input_function(func):
|
|||||||
values = ValueSet(iterate())
|
values = ValueSet(iterate())
|
||||||
if values:
|
if values:
|
||||||
return values
|
return values
|
||||||
return obj.py__call__(arguments)
|
return value.py__call__(arguments)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
@@ -738,8 +738,8 @@ _implemented = {
|
|||||||
'deepcopy': _return_first_param,
|
'deepcopy': _return_first_param,
|
||||||
},
|
},
|
||||||
'json': {
|
'json': {
|
||||||
'load': lambda obj, arguments, callback: NO_VALUES,
|
'load': lambda value, arguments, callback: NO_VALUES,
|
||||||
'loads': lambda obj, arguments, callback: NO_VALUES,
|
'loads': lambda value, arguments, callback: NO_VALUES,
|
||||||
},
|
},
|
||||||
'collections': {
|
'collections': {
|
||||||
'namedtuple': collections_namedtuple,
|
'namedtuple': collections_namedtuple,
|
||||||
@@ -766,7 +766,7 @@ _implemented = {
|
|||||||
# The _alias function just leads to some annoying type inference.
|
# The _alias function just leads to some annoying type inference.
|
||||||
# Therefore, just make it return nothing, which leads to the stubs
|
# Therefore, just make it return nothing, which leads to the stubs
|
||||||
# being used instead. This only matters for 3.7+.
|
# being used instead. This only matters for 3.7+.
|
||||||
'_alias': lambda obj, arguments, callback: NO_VALUES,
|
'_alias': lambda value, arguments, callback: NO_VALUES,
|
||||||
},
|
},
|
||||||
'dataclasses': {
|
'dataclasses': {
|
||||||
# For now this works at least better than Jedi trying to understand it.
|
# For now this works at least better than Jedi trying to understand it.
|
||||||
@@ -806,8 +806,8 @@ class EnumInstance(LazyValueWrapper):
|
|||||||
return ValueName(self, self._name.tree_name)
|
return ValueName(self, self._name.tree_name)
|
||||||
|
|
||||||
def _get_wrapped_value(self):
|
def _get_wrapped_value(self):
|
||||||
obj, = self._cls.execute_with_values()
|
value, = self._cls.execute_with_values()
|
||||||
return obj
|
return value
|
||||||
|
|
||||||
def get_filters(self, origin_scope=None):
|
def get_filters(self, origin_scope=None):
|
||||||
yield DictFilter(dict(
|
yield DictFilter(dict(
|
||||||
|
|||||||
Reference in New Issue
Block a user