infer_state -> inference_state

This commit is contained in:
Dave Halter committed 2019-08-16 11:44:30 +02:00
1 parent fffb39227e
commit 03920502c4
60 files changed
+727 -727

No files matched your search

+40 -40
View File
@@ -14,7 +14,7 @@ from jedi.inference.names import AbstractNameDefinition, ValueNameMixin, \
from jedi.inference.base_value import Value, ValueSet, NO_VALUES
from jedi.inference.lazy_value import LazyKnownValue
from jedi.inference.compiled.access import _sentinel
from jedi.inference.cache import infer_state_function_cache
from jedi.inference.cache import inference_state_function_cache
from jedi.inference.helpers import reraise_getitem_errors
from jedi.inference.signature import BuiltinSignature
@@ -41,15 +41,15 @@ class CheckAttribute(object):
class CompiledObject(Value):
def __init__(self, infer_state, access_handle, parent_context=None):
super(CompiledObject, self).__init__(infer_state, parent_context)
def __init__(self, inference_state, access_handle, parent_context=None):
super(CompiledObject, self).__init__(inference_state, parent_context)
self.access_handle = access_handle
def py__call__(self, arguments):
return_annotation = self.access_handle.get_return_annotation()
if return_annotation is not None:
# TODO the return annotation may also be a string.
return create_from_access_path(self.infer_state, return_annotation).execute_annotation()
return create_from_access_path(self.inference_state, return_annotation).execute_annotation()
try:
self.access_handle.getattr_paths(u'__call__')
@@ -59,26 +59,26 @@ class CompiledObject(Value):
if self.access_handle.is_class():
from jedi.inference.value import CompiledInstance
return ValueSet([
CompiledInstance(self.infer_state, self.parent_context, self, arguments)
CompiledInstance(self.inference_state, self.parent_context, self, arguments)
])
else:
return ValueSet(self._execute_function(arguments))
@CheckAttribute()
def py__class__(self):
return create_from_access_path(self.infer_state, self.access_handle.py__class__())
return create_from_access_path(self.inference_state, self.access_handle.py__class__())
@CheckAttribute()
def py__mro__(self):
return (self,) + tuple(
create_from_access_path(self.infer_state, access)
create_from_access_path(self.inference_state, access)
for access in self.access_handle.py__mro__accesses()
)
@CheckAttribute()
def py__bases__(self):
return tuple(
create_from_access_path(self.infer_state, access)
create_from_access_path(self.inference_state, access)
for access in self.access_handle.py__bases__()
)
@@ -178,7 +178,7 @@ class CompiledObject(Value):
search_global shouldn't change the fact that there's one dict, this way
there's only one `object`.
"""
return CompiledObjectFilter(self.infer_state, self, is_instance)
return CompiledObjectFilter(self.inference_state, self, is_instance)
@CheckAttribute(u'__getitem__')
def py__simple_getitem__(self, index):
@@ -187,7 +187,7 @@ class CompiledObject(Value):
if access is None:
return NO_VALUES
return ValueSet([create_from_access_path(self.infer_state, access)])
return ValueSet([create_from_access_path(self.inference_state, access)])
def py__getitem__(self, index_value_set, valueualized_node):
all_access_paths = self.access_handle.py__getitem__all_values()
@@ -196,7 +196,7 @@ class CompiledObject(Value):
# object.
return super(CompiledObject, self).py__getitem__(index_value_set, valueualized_node)
return ValueSet(
create_from_access_path(self.infer_state, access)
create_from_access_path(self.inference_state, access)
for access in all_access_paths
)
@@ -215,7 +215,7 @@ class CompiledObject(Value):
return
for access in access_path_list:
yield LazyKnownValue(create_from_access_path(self.infer_state, access))
yield LazyKnownValue(create_from_access_path(self.inference_state, access))
def py__name__(self):
return self.access_handle.py__name__()
@@ -237,12 +237,12 @@ class CompiledObject(Value):
try:
# TODO wtf is this? this is exactly the same as the thing
# below. It uses getattr as well.
self.infer_state.builtins_module.access_handle.getattr_paths(name)
self.inference_state.builtins_module.access_handle.getattr_paths(name)
except AttributeError:
continue
else:
bltn_obj = builtin_from_name(self.infer_state, name)
for result in self.infer_state.execute(bltn_obj, params):
bltn_obj = builtin_from_name(self.inference_state, name)
for result in self.inference_state.execute(bltn_obj, params):
yield result
for type_ in docstrings.infer_return_types(self):
yield type_
@@ -257,20 +257,20 @@ class CompiledObject(Value):
def execute_operation(self, other, operator):
return create_from_access_path(
self.infer_state,
self.inference_state,
self.access_handle.execute_operation(other.access_handle, operator)
)
def negate(self):
return create_from_access_path(self.infer_state, self.access_handle.negate())
return create_from_access_path(self.inference_state, self.access_handle.negate())
def get_metaclasses(self):
return NO_VALUES
class CompiledName(AbstractNameDefinition):
def __init__(self, infer_state, parent_context, name):
self._infer_state = infer_state
def __init__(self, inference_state, parent_context, name):
self._inference_state = inference_state
self.parent_context = parent_context
self.string_name = name
@@ -296,7 +296,7 @@ class CompiledName(AbstractNameDefinition):
@underscore_memoization
def infer(self):
return ValueSet([_create_from_name(
self._infer_state, self.parent_context, self.string_name
self._inference_state, self.parent_context, self.string_name
)])
@@ -322,12 +322,12 @@ class SignatureParamName(ParamNameInterface, AbstractNameDefinition):
def infer(self):
p = self._signature_param
infer_state = self.parent_context.infer_state
inference_state = self.parent_context.inference_state
values = NO_VALUES
if p.has_default:
values = ValueSet([create_from_access_path(infer_state, p.default)])
values = ValueSet([create_from_access_path(inference_state, p.default)])
if p.has_annotation:
annotation = create_from_access_path(infer_state, p.annotation)
annotation = create_from_access_path(inference_state, p.annotation)
values |= annotation.execute_with_values()
return values
@@ -364,8 +364,8 @@ class EmptyCompiledName(AbstractNameDefinition):
completions, just give Jedi the option to return this object. It infers to
nothing.
"""
def __init__(self, infer_state, name):
self.parent_context = infer_state.builtins_module
def __init__(self, inference_state, name):
self.parent_context = inference_state.builtins_module
self.string_name = name
def infer(self):
@@ -375,8 +375,8 @@ class EmptyCompiledName(AbstractNameDefinition):
class CompiledObjectFilter(AbstractFilter):
name_class = CompiledName
def __init__(self, infer_state, compiled_object, is_instance=False):
self._infer_state = infer_state
def __init__(self, inference_state, compiled_object, is_instance=False):
self._inference_state = inference_state
self.compiled_object = compiled_object
self.is_instance = is_instance
@@ -399,7 +399,7 @@ class CompiledObjectFilter(AbstractFilter):
# Always use unicode objects in Python 2 from here.
name = force_unicode(name)
if (is_descriptor and not self._infer_state.allow_descriptor_getattr) or not has_attribute:
if (is_descriptor and not self._inference_state.allow_descriptor_getattr) or not has_attribute:
return [self._get_cached_name(name, is_empty=True)]
if self.is_instance and name not in dir_callback():
@@ -409,7 +409,7 @@ class CompiledObjectFilter(AbstractFilter):
@memoize_method
def _get_cached_name(self, name, is_empty=False):
if is_empty:
return EmptyCompiledName(self._infer_state, name)
return EmptyCompiledName(self._inference_state, name)
else:
return self._create_name(name)
@@ -426,12 +426,12 @@ class CompiledObjectFilter(AbstractFilter):
# ``dir`` doesn't include the type names.
if not self.is_instance and needs_type_completions:
for filter in builtin_from_name(self._infer_state, u'type').get_filters():
for filter in builtin_from_name(self._inference_state, u'type').get_filters():
names += filter.values()
return names
def _create_name(self, name):
return self.name_class(self._infer_state, self.compiled_object, name)
return self.name_class(self._inference_state, self.compiled_object, name)
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self.compiled_object)
@@ -507,7 +507,7 @@ def _parse_function_doc(doc):
return param_str, ret
def _create_from_name(infer_state, compiled_object, name):
def _create_from_name(inference_state, compiled_object, name):
access_paths = compiled_object.access_handle.getattr_paths(name, default=None)
parent_context = compiled_object
if parent_context.is_class():
@@ -516,26 +516,26 @@ def _create_from_name(infer_state, compiled_object, name):
value = None
for access_path in access_paths:
value = create_cached_compiled_object(
infer_state, access_path, parent_context=value
inference_state, access_path, parent_context=value
)
return value
def _normalize_create_args(func):
"""The cache doesn't care about keyword vs. normal args."""
def wrapper(infer_state, obj, parent_context=None):
return func(infer_state, obj, parent_context)
def wrapper(inference_state, obj, parent_context=None):
return func(inference_state, obj, parent_context)
return wrapper
def create_from_access_path(infer_state, access_path):
def create_from_access_path(inference_state, access_path):
parent_context = None
for name, access in access_path.accesses:
parent_context = create_cached_compiled_object(infer_state, access, parent_context)
parent_context = create_cached_compiled_object(inference_state, access, parent_context)
return parent_context
@_normalize_create_args
@infer_state_function_cache()
def create_cached_compiled_object(infer_state, access_handle, parent_context):
return CompiledObject(infer_state, access_handle, parent_context)
@inference_state_function_cache()
def create_cached_compiled_object(inference_state, access_handle, parent_context):
return CompiledObject(inference_state, access_handle, parent_context)