diff --git a/jedi/api/interpreter.py b/jedi/api/interpreter.py index ac4aebd6..bb7268a7 100644 --- a/jedi/api/interpreter.py +++ b/jedi/api/interpreter.py @@ -24,9 +24,9 @@ class MixedModuleContext(ModuleContext): super(MixedModuleContext, self).__init__(tree_module_value) self._namespace_objects = [NamespaceObject(n) for n in namespaces] - def _get_mixed_object(self, compiled_object): + def _get_mixed_object(self, compiled_value): return mixed.MixedObject( - compiled_object=compiled_object, + compiled_value=compiled_value, tree_value=self._value ) @@ -35,7 +35,7 @@ class MixedModuleContext(ModuleContext): yield filter for namespace_obj in self._namespace_objects: - compiled_object = _create(self.inference_state, namespace_obj) - mixed_object = self._get_mixed_object(compiled_object) + compiled_value = _create(self.inference_state, namespace_obj) + mixed_object = self._get_mixed_object(compiled_value) for filter in mixed_object.get_filters(*args, **kwargs): yield filter diff --git a/jedi/inference/compiled/__init__.py b/jedi/inference/compiled/__init__.py index 5cd9986e..b5d435fc 100644 --- a/jedi/inference/compiled/__init__.py +++ b/jedi/inference/compiled/__init__.py @@ -21,23 +21,23 @@ class ExactValue(LazyValueWrapper): This class represents exact values, that makes operations like additions and exact boolean values possible, while still being a "normal" stub. """ - def __init__(self, compiled_obj): - self.inference_state = compiled_obj.inference_state - self._compiled_obj = compiled_obj + def __init__(self, compiled_value): + self.inference_state = compiled_value.inference_state + self._compiled_value = compiled_value def __getattribute__(self, name): if name in ('get_safe_value', 'execute_operation', 'access_handle', 'negate', 'py__bool__', 'is_compiled'): - return getattr(self._compiled_obj, name) + return getattr(self._compiled_value, name) return super(ExactValue, self).__getattribute__(name) def _get_wrapped_value(self): instance, = builtin_from_name( - self.inference_state, self._compiled_obj.name.string_name).execute_with_values() + self.inference_state, self._compiled_value.name.string_name).execute_with_values() return instance def __repr__(self): - return '<%s: %s>' % (self.__class__.__name__, self._compiled_obj) + return '<%s: %s>' % (self.__class__.__name__, self._compiled_value) def create_simple_object(inference_state, obj): @@ -46,11 +46,11 @@ def create_simple_object(inference_state, obj): versions. """ assert type(obj) in (int, float, str, bytes, unicode, slice, complex, bool), obj - compiled_obj = create_from_access_path( + compiled_value = create_from_access_path( inference_state, inference_state.compiled_subprocess.create_simple_object(obj) ) - return ExactValue(compiled_obj) + return ExactValue(compiled_value) def get_string_value_set(inference_state): diff --git a/jedi/inference/compiled/mixed.py b/jedi/inference/compiled/mixed.py index 109702f4..98959fd8 100644 --- a/jedi/inference/compiled/mixed.py +++ b/jedi/inference/compiled/mixed.py @@ -43,19 +43,19 @@ class MixedObject(ValueWrapper): fewer special cases, because we in Python you don't have the same freedoms to modify the runtime. """ - def __init__(self, compiled_object, tree_value): + def __init__(self, compiled_value, tree_value): super(MixedObject, self).__init__(tree_value) - self.compiled_object = compiled_object - self.access_handle = compiled_object.access_handle + self.compiled_value = compiled_value + self.access_handle = compiled_value.access_handle def get_filters(self, *args, **kwargs): yield MixedObjectFilter( - self.inference_state, self.compiled_object, self._wrapped_value) + self.inference_state, self.compiled_value, self._wrapped_value) def get_signatures(self): # Prefer `inspect.signature` over somehow analyzing Python code. It # should be very precise, especially for stuff like `partial`. - return self.compiled_object.get_signatures() + return self.compiled_value.get_signatures() @inference_state_method_cache(default=NO_VALUES) def py__call__(self, arguments): @@ -67,14 +67,14 @@ class MixedObject(ValueWrapper): def get_safe_value(self, default=_sentinel): if default is _sentinel: - return self.compiled_object.get_safe_value() + return self.compiled_value.get_safe_value() else: - return self.compiled_object.get_safe_value(default) + return self.compiled_value.get_safe_value(default) def py__simple_getitem__(self, index): - python_object = self.compiled_object.access_handle.access._obj + python_object = self.compiled_value.access_handle.access._obj if type(python_object) in ALLOWED_GETITEM_TYPES: - return self.compiled_object.py__simple_getitem__(index) + return self.compiled_value.py__simple_getitem__(index) return self._wrapped_value.py__simple_getitem__(index) def _as_context(self): @@ -92,8 +92,8 @@ class MixedObject(ValueWrapper): class MixedContext(CompiledContext, TreeContextMixin): @property - def compiled_object(self): - return self._value.compiled_object + def compiled_value(self): + return self._value.compiled_value class MixedModuleContext(CompiledModuleContext, MixedContext): @@ -102,7 +102,7 @@ class MixedModuleContext(CompiledModuleContext, MixedContext): class MixedName(NameWrapper): """ - The ``CompiledName._compiled_object`` is our MixedObject. + The ``CompiledName._compiled_value`` is our MixedObject. """ def __init__(self, wrapped_name, parent_tree_value): super(MixedName, self).__init__(wrapped_name) @@ -118,20 +118,20 @@ class MixedName(NameWrapper): @memoize_method def infer(self): - compiled_object = self._wrapped_name.infer_compiled_object() + compiled_value = self._wrapped_name.infer_compiled_value() tree_value = self._parent_tree_value if tree_value.is_instance() or tree_value.is_class(): tree_values = tree_value.py__getattribute__(self.string_name) - if compiled_object.is_function(): - return ValueSet({MixedObject(compiled_object, v) for v in tree_values}) + if compiled_value.is_function(): + return ValueSet({MixedObject(compiled_value, v) for v in tree_values}) module_context = tree_value.get_root_context() - return _create(self._inference_state, compiled_object, module_context) + return _create(self._inference_state, compiled_value, module_context) class MixedObjectFilter(compiled.CompiledValueFilter): - def __init__(self, inference_state, compiled_object, tree_value): - super(MixedObjectFilter, self).__init__(inference_state, compiled_object) + def __init__(self, inference_state, compiled_value, tree_value): + super(MixedObjectFilter, self).__init__(inference_state, compiled_value) self._tree_value = tree_value def _create_name(self, name): @@ -250,33 +250,33 @@ def _find_syntax_node_name(inference_state, python_object): @inference_state_function_cache() -def _create(inference_state, compiled_object, module_context): +def _create(inference_state, compiled_value, module_context): # TODO accessing this is bad, but it probably doesn't matter that much, # because we're working with interpreteters only here. - python_object = compiled_object.access_handle.access._obj + python_object = compiled_value.access_handle.access._obj result = _find_syntax_node_name(inference_state, python_object) if result is None: # TODO Care about generics from stuff like `[1]` and don't return like this. if type(python_object) in (dict, list, tuple): - return ValueSet({compiled_object}) + return ValueSet({compiled_value}) - tree_values = to_stub(compiled_object) + tree_values = to_stub(compiled_value) if not tree_values: - return ValueSet({compiled_object}) + return ValueSet({compiled_value}) else: module_node, tree_node, file_io, code_lines = result if module_context is None or module_context.tree_node != module_node: - root_compiled_object = compiled_object.get_root_context().get_value() + root_compiled_value = compiled_value.get_root_context().get_value() # TODO this __name__ might be wrong. - name = root_compiled_object.py__name__() + name = root_compiled_value.py__name__() string_names = tuple(name.split('.')) module_value = ModuleValue( inference_state, module_node, file_io=file_io, string_names=string_names, code_lines=code_lines, - is_package=root_compiled_object.is_package(), + is_package=root_compiled_value.is_package(), ) if name is not None: inference_state.module_cache.add(string_names, ValueSet([module_value])) @@ -284,11 +284,11 @@ def _create(inference_state, compiled_object, module_context): tree_values = ValueSet({module_context.create_value(tree_node)}) if tree_node.type == 'classdef': - if not compiled_object.is_class(): + if not compiled_value.is_class(): # Is an instance, not a class. tree_values = tree_values.execute_with_values() return ValueSet( - MixedObject(compiled_object, tree_value=tree_value) + MixedObject(compiled_value, tree_value=tree_value) for tree_value in tree_values ) diff --git a/jedi/inference/compiled/value.py b/jedi/inference/compiled/value.py index cf7f5918..fe8c03c2 100644 --- a/jedi/inference/compiled/value.py +++ b/jedi/inference/compiled/value.py @@ -354,15 +354,15 @@ class CompiledName(AbstractNameDefinition): @memoize_method def infer(self): - return ValueSet([self.infer_compiled_object()]) + return ValueSet([self.infer_compiled_value()]) - def infer_compiled_object(self): + def infer_compiled_value(self): return create_from_name(self._inference_state, self._parent_value, self.string_name) class SignatureParamName(ParamNameInterface, AbstractNameDefinition): - def __init__(self, compiled_obj, signature_param): - self.parent_context = compiled_obj.parent_context + def __init__(self, compiled_value, signature_param): + self.parent_context = compiled_value.parent_context self._signature_param = signature_param @property @@ -393,8 +393,8 @@ class SignatureParamName(ParamNameInterface, AbstractNameDefinition): class UnresolvableParamName(ParamNameInterface, AbstractNameDefinition): - def __init__(self, compiled_obj, name, default): - self.parent_context = compiled_obj.parent_context + def __init__(self, compiled_value, name, default): + self.parent_context = compiled_value.parent_context self.string_name = name self._default = default @@ -433,13 +433,13 @@ class EmptyCompiledName(AbstractNameDefinition): class CompiledValueFilter(AbstractFilter): - def __init__(self, inference_state, compiled_object, is_instance=False): + def __init__(self, inference_state, compiled_value, is_instance=False): self._inference_state = inference_state - self.compiled_object = compiled_object + self.compiled_value = compiled_value self.is_instance = is_instance def get(self, name): - access_handle = self.compiled_object.access_handle + access_handle = self.compiled_value.access_handle return self._get( name, lambda name, unsafe: access_handle.is_allowed_getattr(name, unsafe), @@ -482,7 +482,7 @@ class CompiledValueFilter(AbstractFilter): def values(self): from jedi.inference.compiled import builtin_from_name names = [] - needs_type_completions, dir_infos = self.compiled_object.access_handle.get_dir_infos() + needs_type_completions, dir_infos = self.compiled_value.access_handle.get_dir_infos() # We could use `unsafe` here as well, especially as a parameter to # get_dir_infos. But this would lead to a lot of property executions # that are probably not wanted. The drawback for this is that we @@ -504,12 +504,12 @@ class CompiledValueFilter(AbstractFilter): def _create_name(self, name): return CompiledName( self._inference_state, - self.compiled_object, + self.compiled_value, name ) def __repr__(self): - return "<%s: %s>" % (self.__class__.__name__, self.compiled_object) + return "<%s: %s>" % (self.__class__.__name__, self.compiled_value) docstr_defaults = { @@ -582,15 +582,15 @@ def _parse_function_doc(doc): return param_str, ret -def create_from_name(inference_state, compiled_object, name): - access_paths = compiled_object.access_handle.getattr_paths(name, default=None) - parent_context = compiled_object +def create_from_name(inference_state, compiled_value, name): + access_paths = compiled_value.access_handle.getattr_paths(name, default=None) + parent_context = compiled_value if parent_context.is_class(): parent_context = parent_context.parent_context value = None for access_path in access_paths: - value = create_cached_compiled_object( + value = create_cached_compiled_value( inference_state, access_path, parent_context=None if value is None else value.as_context(), @@ -608,7 +608,7 @@ def _normalize_create_args(func): def create_from_access_path(inference_state, access_path): value = None for name, access in access_path.accesses: - value = create_cached_compiled_object( + value = create_cached_compiled_value( inference_state, access, parent_context=None if value is None else value.as_context() @@ -618,7 +618,7 @@ def create_from_access_path(inference_state, access_path): @_normalize_create_args @inference_state_function_cache() -def create_cached_compiled_object(inference_state, access_handle, parent_context): +def create_cached_compiled_value(inference_state, access_handle, parent_context): assert not isinstance(parent_context, CompiledValue) if parent_context is None: cls = CompiledModule diff --git a/jedi/inference/value/instance.py b/jedi/inference/value/instance.py index d0529604..858c778e 100644 --- a/jedi/inference/value/instance.py +++ b/jedi/inference/value/instance.py @@ -432,7 +432,7 @@ class CompiledInstanceClassFilter(AbstractFilter): return self._convert(self._class_filter.values()) def _convert(self, names): - klass = self._class_filter.compiled_object + klass = self._class_filter.compiled_value return [ CompiledInstanceName(self._instance.inference_state, self._instance, klass, n) for n in names diff --git a/jedi/inference/value/iterable.py b/jedi/inference/value/iterable.py index b79c7c58..236ea851 100644 --- a/jedi/inference/value/iterable.py +++ b/jedi/inference/value/iterable.py @@ -426,10 +426,10 @@ class DictLiteralValue(_DictMixin, SequenceLiteralValue, _DictKeyMixin): def py__simple_getitem__(self, index): """Here the index is an int/str. Raises IndexError/KeyError.""" - compiled_obj_index = compiled.create_simple_object(self.inference_state, index) + compiled_value_index = compiled.create_simple_object(self.inference_state, index) for key, value in self.get_tree_entries(): for k in self._defining_context.infer_node(key): - for key_v in k.execute_operation(compiled_obj_index, u'=='): + for key_v in k.execute_operation(compiled_value_index, u'=='): if key_v.get_safe_value(): return self._defining_context.infer_node(value) raise SimpleGetItemNotFound('No key found in dictionary %s.' % self)