From 8cccdde28d38e0b6d2720a6e3b042b0782de2caa Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 25 Jan 2020 18:13:50 +0100 Subject: [PATCH] CompiledObject -> CompiledValue --- jedi/inference/arguments.py | 2 +- jedi/inference/compiled/__init__.py | 4 ++-- jedi/inference/compiled/mixed.py | 6 +++--- jedi/inference/compiled/value.py | 24 ++++++++++++------------ jedi/inference/value/instance.py | 4 ++-- jedi/inference/value/iterable.py | 2 +- test/test_inference/test_compiled.py | 6 +++--- test/test_inference/test_precedence.py | 4 ++-- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/jedi/inference/arguments.py b/jedi/inference/arguments.py index d7edeb4f..c9404478 100644 --- a/jedi/inference/arguments.py +++ b/jedi/inference/arguments.py @@ -18,7 +18,7 @@ def try_iter_content(types, depth=0): """Helper method for static analysis.""" if depth > 10: # It's possible that a loop has references on itself (especially with - # CompiledObject). Therefore don't loop infinitely. + # CompiledValue). Therefore don't loop infinitely. return for typ in types: diff --git a/jedi/inference/compiled/__init__.py b/jedi/inference/compiled/__init__.py index a900c243..5cd9986e 100644 --- a/jedi/inference/compiled/__init__.py +++ b/jedi/inference/compiled/__init__.py @@ -1,6 +1,6 @@ from jedi._compatibility import unicode -from jedi.inference.compiled.value import CompiledObject, CompiledName, \ - CompiledObjectFilter, CompiledValueName, create_from_access_path +from jedi.inference.compiled.value import CompiledValue, CompiledName, \ + CompiledValueFilter, CompiledValueName, create_from_access_path from jedi.inference.base_value import LazyValueWrapper diff --git a/jedi/inference/compiled/mixed.py b/jedi/inference/compiled/mixed.py index 261a63d2..109702f4 100644 --- a/jedi/inference/compiled/mixed.py +++ b/jedi/inference/compiled/mixed.py @@ -32,13 +32,13 @@ class MixedObject(ValueWrapper): 1. It uses the default logic of ``parser.python.tree`` objects, 2. except for getattr calls and signatures. The names dicts are generated - in a fashion like ``CompiledObject``. + in a fashion like ``CompiledValue``. This combined logic makes it possible to provide more powerful REPL completion. It allows side effects that are not noticable with the default parser structure to still be completeable. - The biggest difference from CompiledObject to MixedObject is that we are + The biggest difference from CompiledValue to MixedObject is that we are generally dealing with Python code and not with C code. This will generate fewer special cases, because we in Python you don't have the same freedoms to modify the runtime. @@ -129,7 +129,7 @@ class MixedName(NameWrapper): return _create(self._inference_state, compiled_object, module_context) -class MixedObjectFilter(compiled.CompiledObjectFilter): +class MixedObjectFilter(compiled.CompiledValueFilter): def __init__(self, inference_state, compiled_object, tree_value): super(MixedObjectFilter, self).__init__(inference_state, compiled_object) self._tree_value = tree_value diff --git a/jedi/inference/compiled/value.py b/jedi/inference/compiled/value.py index 22c64e3e..cf7f5918 100644 --- a/jedi/inference/compiled/value.py +++ b/jedi/inference/compiled/value.py @@ -41,9 +41,9 @@ class CheckAttribute(object): return partial(self.func, instance) -class CompiledObject(Value): +class CompiledValue(Value): def __init__(self, inference_state, access_handle, parent_context=None): - super(CompiledObject, self).__init__(inference_state, parent_context) + super(CompiledValue, self).__init__(inference_state, parent_context) self.access_handle = access_handle def py__call__(self, arguments): @@ -58,7 +58,7 @@ class CompiledObject(Value): try: self.access_handle.getattr_paths(u'__call__') except AttributeError: - return super(CompiledObject, self).py__call__(arguments) + return super(CompiledValue, self).py__call__(arguments) else: if self.access_handle.is_class(): from jedi.inference.value import CompiledInstance @@ -156,14 +156,14 @@ class CompiledObject(Value): @memoize_method def _ensure_one_filter(self, is_instance): - return CompiledObjectFilter(self.inference_state, self, is_instance) + return CompiledValueFilter(self.inference_state, self, is_instance) def py__simple_getitem__(self, index): with reraise_getitem_errors(IndexError, KeyError, TypeError): try: access = self.access_handle.py__simple_getitem__(index) except AttributeError: - return super(CompiledObject, self).py__simple_getitem__(index) + return super(CompiledValue, self).py__simple_getitem__(index) if access is None: return NO_VALUES @@ -174,7 +174,7 @@ class CompiledObject(Value): if all_access_paths is None: # This means basically that no __getitem__ has been defined on this # object. - return super(CompiledObject, self).py__getitem__(index_value_set, contextualized_node) + return super(CompiledValue, self).py__getitem__(index_value_set, contextualized_node) return ValueSet( create_from_access_path(self.inference_state, access) for access in all_access_paths @@ -186,7 +186,7 @@ class CompiledObject(Value): # just start with __getitem__(0). This is especially true for # Python 2 strings, where `str.__iter__` is not even defined. if not self.access_handle.has_iter(): - for x in super(CompiledObject, self).py__iter__(contextualized_node): + for x in super(CompiledValue, self).py__iter__(contextualized_node): yield x access_path_list = self.access_handle.py__iter__list() @@ -264,7 +264,7 @@ class CompiledObject(Value): v.with_generics(arguments) for v in self.inference_state.typing_module.py__getattribute__(name) ]).execute_annotation() - return super(CompiledObject, self).execute_annotation() + return super(CompiledValue, self).execute_annotation() def negate(self): return create_from_access_path(self.inference_state, self.access_handle.negate()) @@ -286,7 +286,7 @@ class CompiledObject(Value): ] -class CompiledModule(CompiledObject): +class CompiledModule(CompiledValue): file_io = None # For modules def _as_context(self): @@ -432,7 +432,7 @@ class EmptyCompiledName(AbstractNameDefinition): return NO_VALUES -class CompiledObjectFilter(AbstractFilter): +class CompiledValueFilter(AbstractFilter): def __init__(self, inference_state, compiled_object, is_instance=False): self._inference_state = inference_state self.compiled_object = compiled_object @@ -619,9 +619,9 @@ 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): - assert not isinstance(parent_context, CompiledObject) + assert not isinstance(parent_context, CompiledValue) if parent_context is None: cls = CompiledModule else: - cls = CompiledObject + cls = CompiledValue return cls(inference_state, access_handle, parent_context) diff --git a/jedi/inference/value/instance.py b/jedi/inference/value/instance.py index af0a59e4..d0529604 100644 --- a/jedi/inference/value/instance.py +++ b/jedi/inference/value/instance.py @@ -5,7 +5,7 @@ from parso.python.tree import search_ancestor from jedi import debug from jedi import settings from jedi.inference import compiled -from jedi.inference.compiled.value import CompiledObjectFilter +from jedi.inference.compiled.value import CompiledValueFilter from jedi.inference.helpers import values_from_qualified_names, is_big_annoying_library from jedi.inference.filters import AbstractFilter, AnonymousFunctionExecutionFilter from jedi.inference.names import ValueName, TreeNameDefinition, ParamName, \ @@ -189,7 +189,7 @@ class _BaseTreeInstance(AbstractInstanceValue): for f in class_filters: if isinstance(f, ClassFilter): yield InstanceClassFilter(self, f) - elif isinstance(f, CompiledObjectFilter): + elif isinstance(f, CompiledValueFilter): yield CompiledInstanceClassFilter(self, f) else: # Propably from the metaclass. diff --git a/jedi/inference/value/iterable.py b/jedi/inference/value/iterable.py index 92f8c3cb..b79c7c58 100644 --- a/jedi/inference/value/iterable.py +++ b/jedi/inference/value/iterable.py @@ -634,7 +634,7 @@ class Slice(LazyValueWrapper): def get_safe_value(self, default=sentinel): """ - Imitate CompiledObject.obj behavior and return a ``builtin.slice()`` + Imitate CompiledValue.obj behavior and return a ``builtin.slice()`` object. """ def get(element): diff --git a/test/test_inference/test_compiled.py b/test/test_inference/test_compiled.py index 39f24c07..cab6e27c 100644 --- a/test/test_inference/test_compiled.py +++ b/test/test_inference/test_compiled.py @@ -50,7 +50,7 @@ def test_parse_function_doc_illegal_docstr(): def test_doc(inference_state): """ - Even CompiledObject docs always return empty docstrings - not None, that's + Even CompiledValue docs always return empty docstrings - not None, that's just a Jedi API definition. """ str_ = compiled.create_simple_object(inference_state, u'') @@ -135,7 +135,7 @@ def test_parent_context(same_process_inference_state, attribute, expected_name, dt = datetime(2000, 1, 1) ret_int = _return_int - o = compiled.CompiledObject( + o = compiled.CompiledValue( same_process_inference_state, DirectObjectAccess(same_process_inference_state, C) ) @@ -165,7 +165,7 @@ def test_parent_context(same_process_inference_state, attribute, expected_name, ] ) def test_qualified_names(same_process_inference_state, obj, expected_names): - o = compiled.CompiledObject( + o = compiled.CompiledValue( same_process_inference_state, DirectObjectAccess(same_process_inference_state, obj) ) diff --git a/test/test_inference/test_precedence.py b/test/test_inference/test_precedence.py index 4b41bcd8..9cb70a57 100644 --- a/test/test_inference/test_precedence.py +++ b/test/test_inference/test_precedence.py @@ -1,4 +1,4 @@ -from jedi.inference.compiled import CompiledObject +from jedi.inference.compiled import CompiledValue import pytest @@ -15,4 +15,4 @@ def test_equals(Script, environment, source): script = Script(source) node = script._module_node.children[0] first, = script._get_module_context().infer_node(node) - assert isinstance(first, CompiledObject) and first.get_safe_value() is True + assert isinstance(first, CompiledValue) and first.get_safe_value() is True