Skip to content

Commit

Permalink
CompiledObject -> CompiledValue
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhalter committed Jan 25, 2020
1 parent 5cd4a52 commit 8cccdde
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion jedi/inference/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions jedi/inference/compiled/__init__.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
6 changes: 3 additions & 3 deletions jedi/inference/compiled/mixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -129,7 +129,7 @@ def infer(self):
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
Expand Down
24 changes: 12 additions & 12 deletions jedi/inference/compiled/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def __get__(self, instance, owner):
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):
Expand All @@ -58,7 +58,7 @@ def py__call__(self, arguments):
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
Expand Down Expand Up @@ -156,14 +156,14 @@ def get_filters(self, is_instance=False, origin_scope=None):

@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

Expand All @@ -174,7 +174,7 @@ def py__getitem__(self, index_value_set, contextualized_node):
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
Expand All @@ -186,7 +186,7 @@ def py__iter__(self, contextualized_node=None):
# 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()
Expand Down Expand Up @@ -264,7 +264,7 @@ def execute_annotation(self):
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())
Expand All @@ -286,7 +286,7 @@ def get_key_values(self):
]


class CompiledModule(CompiledObject):
class CompiledModule(CompiledValue):
file_io = None # For modules

def _as_context(self):
Expand Down Expand Up @@ -432,7 +432,7 @@ def infer(self):
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
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions jedi/inference/value/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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, \
Expand Down Expand Up @@ -189,7 +189,7 @@ def get_filters(self, origin_scope=None, include_self_names=True):
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.
Expand Down
2 changes: 1 addition & 1 deletion jedi/inference/value/iterable.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def _get_wrapped_value(self):

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):
Expand Down
6 changes: 3 additions & 3 deletions test/test_inference/test_compiled.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'')
Expand Down Expand Up @@ -135,7 +135,7 @@ class C:
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)
)
Expand Down Expand Up @@ -165,7 +165,7 @@ class C:
]
)
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)
)
Expand Down
4 changes: 2 additions & 2 deletions test/test_inference/test_precedence.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from jedi.inference.compiled import CompiledObject
from jedi.inference.compiled import CompiledValue

import pytest

Expand All @@ -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

0 comments on commit 8cccdde

Please sign in to comment.