1
0
forked from VimPlug/jedi

infer_state -> inference_state

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

View File

@@ -2,7 +2,7 @@ from parso.python import tree
from jedi._compatibility import use_metaclass
from jedi import debug
from jedi.inference.cache import infer_state_method_cache, CachedMetaClass
from jedi.inference.cache import inference_state_method_cache, CachedMetaClass
from jedi.inference import compiled
from jedi.inference import recursion
from jedi.inference import docstrings
@@ -97,7 +97,7 @@ class FunctionMixin(object):
if arguments is None:
arguments = AnonymousArguments()
return FunctionExecutionValue(self.infer_state, self.parent_context, self, arguments)
return FunctionExecutionValue(self.inference_state, self.parent_context, self, arguments)
def get_signatures(self):
return [TreeSignature(f) for f in self.get_signature_functions()]
@@ -112,14 +112,14 @@ class FunctionValue(use_metaclass(CachedMetaClass, FunctionMixin, FunctionAndCla
def create(tree_node):
if value.is_class():
return MethodValue(
value.infer_state,
value.inference_state,
value,
parent_context=parent_context,
tree_node=tree_node
)
else:
return cls(
value.infer_state,
value.inference_state,
parent_context=parent_context,
tree_node=tree_node
)
@@ -140,7 +140,7 @@ class FunctionValue(use_metaclass(CachedMetaClass, FunctionMixin, FunctionAndCla
return function
def py__class__(self):
c, = values_from_qualified_names(self.infer_state, u'types', u'FunctionType')
c, = values_from_qualified_names(self.inference_state, u'types', u'FunctionType')
return c
def get_default_param_value(self):
@@ -151,8 +151,8 @@ class FunctionValue(use_metaclass(CachedMetaClass, FunctionMixin, FunctionAndCla
class MethodValue(FunctionValue):
def __init__(self, infer_state, class_value, *args, **kwargs):
super(MethodValue, self).__init__(infer_state, *args, **kwargs)
def __init__(self, inference_state, class_value, *args, **kwargs):
super(MethodValue, self).__init__(inference_state, *args, **kwargs)
self.class_value = class_value
def get_default_param_value(self):
@@ -170,16 +170,16 @@ class MethodValue(FunctionValue):
class FunctionExecutionValue(TreeValue):
function_execution_filter = FunctionExecutionFilter
def __init__(self, infer_state, parent_context, function_value, var_args):
def __init__(self, inference_state, parent_context, function_value, var_args):
super(FunctionExecutionValue, self).__init__(
infer_state,
inference_state,
parent_context,
function_value.tree_node,
)
self.function_value = function_value
self.var_args = var_args
@infer_state_method_cache(default=NO_VALUES)
@inference_state_method_cache(default=NO_VALUES)
@recursion.execution_recursion_decorator()
def get_return_values(self, check_yields=False):
funcdef = self.tree_node
@@ -188,7 +188,7 @@ class FunctionExecutionValue(TreeValue):
if check_yields:
value_set = NO_VALUES
returns = get_yield_exprs(self.infer_state, funcdef)
returns = get_yield_exprs(self.inference_state, funcdef)
else:
returns = funcdef.iter_return_stmts()
from jedi.inference.gradual.annotation import infer_return_types
@@ -213,7 +213,7 @@ class FunctionExecutionValue(TreeValue):
try:
children = r.children
except AttributeError:
ctx = compiled.builtin_from_name(self.infer_state, u'None')
ctx = compiled.builtin_from_name(self.inference_state, u'None')
value_set |= ValueSet([ctx])
else:
value_set |= self.infer_node(children[1])
@@ -225,7 +225,7 @@ class FunctionExecutionValue(TreeValue):
def _get_yield_lazy_value(self, yield_expr):
if yield_expr.type == 'keyword':
# `yield` just yields None.
ctx = compiled.builtin_from_name(self.infer_state, u'None')
ctx = compiled.builtin_from_name(self.inference_state, u'None')
yield LazyKnownValue(ctx)
return
@@ -242,7 +242,7 @@ class FunctionExecutionValue(TreeValue):
# TODO: if is_async, wrap yield statements in Awaitable/async_generator_asend
for_parents = [(y, tree.search_ancestor(y, 'for_stmt', 'funcdef',
'while_stmt', 'if_stmt'))
for y in get_yield_exprs(self.infer_state, self.tree_node)]
for y in get_yield_exprs(self.inference_state, self.tree_node)]
# Calculate if the yields are placed within the same for loop.
yields_order = []
@@ -297,7 +297,7 @@ class FunctionExecutionValue(TreeValue):
until_position=until_position,
origin_scope=origin_scope)
@infer_state_method_cache()
@inference_state_method_cache()
def get_executed_params_and_issues(self):
return self.var_args.get_executed_params_and_issues(self)
@@ -322,16 +322,16 @@ class FunctionExecutionValue(TreeValue):
"""
Created to be used by inheritance.
"""
infer_state = self.infer_state
inference_state = self.inference_state
is_coroutine = self.tree_node.parent.type in ('async_stmt', 'async_funcdef')
is_generator = bool(get_yield_exprs(infer_state, self.tree_node))
is_generator = bool(get_yield_exprs(inference_state, self.tree_node))
from jedi.inference.gradual.typing import GenericClass
if is_coroutine:
if is_generator:
if infer_state.environment.version_info < (3, 6):
if inference_state.environment.version_info < (3, 6):
return NO_VALUES
async_generator_classes = infer_state.typing_module \
async_generator_classes = inference_state.typing_module \
.py__getattribute__('AsyncGenerator')
yield_values = self.merge_yield_values(is_async=True)
@@ -343,9 +343,9 @@ class FunctionExecutionValue(TreeValue):
for c in async_generator_classes
).execute_annotation()
else:
if infer_state.environment.version_info < (3, 5):
if inference_state.environment.version_info < (3, 5):
return NO_VALUES
async_classes = infer_state.typing_module.py__getattribute__('Coroutine')
async_classes = inference_state.typing_module.py__getattribute__('Coroutine')
return_values = self.get_return_values()
# Only the first generic is relevant.
generics = (return_values.py__class__(), NO_VALUES, NO_VALUES)
@@ -354,7 +354,7 @@ class FunctionExecutionValue(TreeValue):
).execute_annotation()
else:
if is_generator:
return ValueSet([iterable.Generator(infer_state, self)])
return ValueSet([iterable.Generator(inference_state, self)])
else:
return self.get_return_values()
@@ -379,7 +379,7 @@ class OverloadedFunctionValue(FunctionMixin, ValueWrapper):
if matched:
return value_set
if self.infer_state.is_analysis:
if self.inference_state.is_analysis:
# In this case we want precision.
return NO_VALUES
return ValueSet.from_sets(fe.infer() for fe in function_executions)
@@ -411,7 +411,7 @@ def _find_overload_functions(value, tree_node):
while True:
filter = ParserTreeFilter(
value.infer_state,
value.inference_state,
value,
until_position=tree_node.start_pos
)

View File

@@ -10,7 +10,7 @@ from jedi.inference.names import ValueName, TreeNameDefinition
from jedi.inference.base_value import Value, NO_VALUES, ValueSet, \
iterator_to_value_set, ValueWrapper
from jedi.inference.lazy_value import LazyKnownValue, LazyKnownValues
from jedi.inference.cache import infer_state_method_cache
from jedi.inference.cache import inference_state_method_cache
from jedi.inference.arguments import AnonymousArguments, \
ValuesArguments, TreeArgumentsWrapper
from jedi.inference.value.function import \
@@ -50,7 +50,7 @@ class AnonymousInstanceArguments(AnonymousArguments):
# executions of this function, we have all the params already.
return [self_param], []
executed_params = list(search_params(
execution_value.infer_state,
execution_value.inference_state,
execution_value,
execution_value.tree_node
))
@@ -61,8 +61,8 @@ class AnonymousInstanceArguments(AnonymousArguments):
class AbstractInstanceValue(Value):
api_type = u'instance'
def __init__(self, infer_state, parent_context, class_value, var_args):
super(AbstractInstanceValue, self).__init__(infer_state, parent_context)
def __init__(self, inference_state, parent_context, class_value, var_args):
super(AbstractInstanceValue, self).__init__(inference_state, parent_context)
# Generated instances are classes that are just generated by self
# (No var_args) used.
self.class_value = class_value
@@ -117,7 +117,7 @@ class AbstractInstanceValue(Value):
names = self.get_function_slot_names(u'__get__')
if names:
if obj is None:
obj = compiled.builtin_from_name(self.infer_state, u'None')
obj = compiled.builtin_from_name(self.inference_state, u'None')
return self.execute_function_slots(names, obj, class_value)
else:
return ValueSet([self])
@@ -168,7 +168,7 @@ class AbstractInstanceValue(Value):
for generator in self.execute_function_slots(iter_slot_names):
if generator.is_instance() and not generator.is_compiled():
# `__next__` logic.
if self.infer_state.environment.version_info.major == 2:
if self.inference_state.environment.version_info.major == 2:
name = u'next'
else:
name = u'__next__'
@@ -199,7 +199,7 @@ class AbstractInstanceValue(Value):
bound_method = BoundMethod(self, function)
yield bound_method.get_function_execution(self.var_args)
@infer_state_method_cache()
@inference_state_method_cache()
def create_instance_value(self, class_value, node):
if node.parent.type in ('funcdef', 'classdef'):
node = node.parent
@@ -219,7 +219,7 @@ class AbstractInstanceValue(Value):
else:
return bound_method.get_function_execution()
elif scope.type == 'classdef':
class_value = ClassValue(self.infer_state, parent_context, scope)
class_value = ClassValue(self.inference_state, parent_context, scope)
return class_value
elif scope.type in ('comp_for', 'sync_comp_for'):
# Comprehensions currently don't have a special scope in Jedi.
@@ -238,9 +238,9 @@ class AbstractInstanceValue(Value):
class CompiledInstance(AbstractInstanceValue):
def __init__(self, infer_state, parent_context, class_value, var_args):
def __init__(self, inference_state, parent_context, class_value, var_args):
self._original_var_args = var_args
super(CompiledInstance, self).__init__(infer_state, parent_context, class_value, var_args)
super(CompiledInstance, self).__init__(inference_state, parent_context, class_value, var_args)
@property
def name(self):
@@ -258,16 +258,16 @@ class CompiledInstance(AbstractInstanceValue):
class TreeInstance(AbstractInstanceValue):
def __init__(self, infer_state, parent_context, class_value, var_args):
def __init__(self, inference_state, parent_context, class_value, var_args):
# I don't think that dynamic append lookups should happen here. That
# sounds more like something that should go to py__iter__.
if class_value.py__name__() in ['list', 'set'] \
and parent_context.get_root_value() == infer_state.builtins_module:
and parent_context.get_root_value() == inference_state.builtins_module:
# compare the module path with the builtin name.
if settings.dynamic_array_additions:
var_args = iterable.get_dynamic_array_instance(self, var_args)
super(TreeInstance, self).__init__(infer_state, parent_context,
super(TreeInstance, self).__init__(inference_state, parent_context,
class_value, var_args)
self.tree_node = class_value.tree_node
@@ -277,7 +277,7 @@ class TreeInstance(AbstractInstanceValue):
# This can recurse, if the initialization of the class includes a reference
# to itself.
@infer_state_method_cache(default=None)
@inference_state_method_cache(default=None)
def _get_annotated_class_object(self):
from jedi.inference.gradual.annotation import py__annotations__, \
infer_type_vars_for_execution
@@ -313,9 +313,9 @@ class TreeInstance(AbstractInstanceValue):
class AnonymousInstance(TreeInstance):
def __init__(self, infer_state, parent_context, class_value):
def __init__(self, inference_state, parent_context, class_value):
super(AnonymousInstance, self).__init__(
infer_state,
inference_state,
parent_context,
class_value,
var_args=AnonymousInstanceArguments(self),
@@ -327,9 +327,9 @@ class AnonymousInstance(TreeInstance):
class CompiledInstanceName(compiled.CompiledName):
def __init__(self, infer_state, instance, klass, name):
def __init__(self, inference_state, instance, klass, name):
super(CompiledInstanceName, self).__init__(
infer_state,
inference_state,
klass.parent_context,
name.string_name
)
@@ -361,7 +361,7 @@ class CompiledInstanceClassFilter(AbstractFilter):
def _convert(self, names):
klass = self._class_filter.compiled_object
return [
CompiledInstanceName(self._instance.infer_state, self._instance, klass, n)
CompiledInstanceName(self._instance.inference_state, self._instance, klass, n)
for n in names
]
@@ -375,7 +375,7 @@ class BoundMethod(FunctionMixin, ValueWrapper):
return True
def py__class__(self):
c, = values_from_qualified_names(self.infer_state, u'types', u'MethodType')
c, = values_from_qualified_names(self.inference_state, u'types', u'MethodType')
return c
def _get_arguments(self, arguments):

View File

@@ -34,7 +34,7 @@ from jedi.inference.helpers import get_int_or_none, is_string, \
predefine_names, infer_call_of_leaf, reraise_getitem_errors, \
SimpleGetItemNotFound
from jedi.inference.utils import safe_property, to_list
from jedi.inference.cache import infer_state_method_cache
from jedi.inference.cache import inference_state_method_cache
from jedi.inference.filters import ParserTreeFilter, LazyAttributeOverwrite, \
publish_method
from jedi.inference.base_value import ValueSet, Value, NO_VALUES, \
@@ -44,7 +44,7 @@ from jedi.parser_utils import get_sync_comp_fors
class IterableMixin(object):
def py__stop_iteration_returns(self):
return ValueSet([compiled.builtin_from_name(self.infer_state, u'None')])
return ValueSet([compiled.builtin_from_name(self.inference_state, u'None')])
# At the moment, safe values are simple values like "foo", 1 and not
# lists/dicts. Therefore as a small speed optimization we can just do the
@@ -66,7 +66,7 @@ class GeneratorBase(LazyAttributeOverwrite, IterableMixin):
array_type = None
def _get_wrapped_value(self):
generator, = self.infer_state.typing_module \
generator, = self.inference_state.typing_module \
.py__getattribute__('Generator') \
.execute_annotation()
return generator
@@ -88,7 +88,7 @@ class GeneratorBase(LazyAttributeOverwrite, IterableMixin):
return ValueSet.from_sets(lazy_value.infer() for lazy_value in self.py__iter__())
def py__stop_iteration_returns(self):
return ValueSet([compiled.builtin_from_name(self.infer_state, u'None')])
return ValueSet([compiled.builtin_from_name(self.inference_state, u'None')])
@property
def name(self):
@@ -97,8 +97,8 @@ class GeneratorBase(LazyAttributeOverwrite, IterableMixin):
class Generator(GeneratorBase):
"""Handling of `yield` functions."""
def __init__(self, infer_state, func_execution_value):
super(Generator, self).__init__(infer_state)
def __init__(self, inference_state, func_execution_value):
super(Generator, self).__init__(inference_state)
self._func_execution_value = func_execution_value
def py__iter__(self, valueualized_node=None):
@@ -114,13 +114,13 @@ class Generator(GeneratorBase):
class CompForValue(TreeValue):
@classmethod
def from_comp_for(cls, parent_context, comp_for):
return cls(parent_context.infer_state, parent_context, comp_for)
return cls(parent_context.inference_state, parent_context, comp_for)
def get_filters(self, search_global=False, until_position=None, origin_scope=None):
yield ParserTreeFilter(self)
def comprehension_from_atom(infer_state, value, atom):
def comprehension_from_atom(inference_state, value, atom):
bracket = atom.children[0]
test_list_comp = atom.children[1]
@@ -131,7 +131,7 @@ def comprehension_from_atom(infer_state, value, atom):
sync_comp_for = sync_comp_for.children[1]
return DictComprehension(
infer_state,
inference_state,
value,
sync_comp_for_node=sync_comp_for,
key_node=test_list_comp.children[0],
@@ -149,7 +149,7 @@ def comprehension_from_atom(infer_state, value, atom):
sync_comp_for = sync_comp_for.children[1]
return cls(
infer_state,
inference_state,
defining_value=value,
sync_comp_for_node=sync_comp_for,
entry_node=test_list_comp.children[0],
@@ -157,7 +157,7 @@ def comprehension_from_atom(infer_state, value, atom):
class ComprehensionMixin(object):
@infer_state_method_cache()
@inference_state_method_cache()
def _get_comp_for_value(self, parent_context, comp_for):
return CompForValue.from_comp_for(parent_context, comp_for)
@@ -192,7 +192,7 @@ class ComprehensionMixin(object):
else:
yield iterated
@infer_state_method_cache(default=[])
@inference_state_method_cache(default=[])
@to_list
def _iterate(self):
comp_fors = tuple(get_sync_comp_fors(self._sync_comp_for_node))
@@ -224,7 +224,7 @@ class Sequence(LazyAttributeOverwrite, IterableMixin):
def _get_wrapped_value(self):
from jedi.inference.gradual.typing import GenericClass
klass = compiled.builtin_from_name(self.infer_state, self.array_type)
klass = compiled.builtin_from_name(self.inference_state, self.array_type)
c, = GenericClass(klass, self._get_generics()).execute_annotation()
return c
@@ -232,11 +232,11 @@ class Sequence(LazyAttributeOverwrite, IterableMixin):
return None # We don't know the length, because of appends.
def py__class__(self):
return compiled.builtin_from_name(self.infer_state, self.array_type)
return compiled.builtin_from_name(self.inference_state, self.array_type)
@safe_property
def parent(self):
return self.infer_state.builtins_module
return self.inference_state.builtins_module
def py__getitem__(self, index_value_set, valueualized_node):
if self.array_type == 'dict':
@@ -245,9 +245,9 @@ class Sequence(LazyAttributeOverwrite, IterableMixin):
class _BaseComprehension(ComprehensionMixin):
def __init__(self, infer_state, defining_value, sync_comp_for_node, entry_node):
def __init__(self, inference_state, defining_value, sync_comp_for_node, entry_node):
assert sync_comp_for_node.type == 'sync_comp_for'
super(_BaseComprehension, self).__init__(infer_state)
super(_BaseComprehension, self).__init__(inference_state)
self._defining_value = defining_value
self._sync_comp_for_node = sync_comp_for_node
self._entry_node = entry_node
@@ -277,9 +277,9 @@ class GeneratorComprehension(_BaseComprehension, GeneratorBase):
class DictComprehension(ComprehensionMixin, Sequence):
array_type = u'dict'
def __init__(self, infer_state, defining_value, sync_comp_for_node, key_node, value_node):
def __init__(self, inference_state, defining_value, sync_comp_for_node, key_node, value_node):
assert sync_comp_for_node.type == 'sync_comp_for'
super(DictComprehension, self).__init__(infer_state)
super(DictComprehension, self).__init__(inference_state)
self._defining_value = defining_value
self._sync_comp_for_node = sync_comp_for_node
self._entry_node = key_node
@@ -308,14 +308,14 @@ class DictComprehension(ComprehensionMixin, Sequence):
@publish_method('values')
def _imitate_values(self):
lazy_value = LazyKnownValues(self._dict_values())
return ValueSet([FakeSequence(self.infer_state, u'list', [lazy_value])])
return ValueSet([FakeSequence(self.inference_state, u'list', [lazy_value])])
@publish_method('items')
def _imitate_items(self):
lazy_values = [
LazyKnownValue(
FakeSequence(
self.infer_state,
self.inference_state,
u'tuple',
[LazyKnownValues(key),
LazyKnownValues(value)]
@@ -324,7 +324,7 @@ class DictComprehension(ComprehensionMixin, Sequence):
for key, value in self._iterate()
]
return ValueSet([FakeSequence(self.infer_state, u'list', lazy_values)])
return ValueSet([FakeSequence(self.inference_state, u'list', lazy_values)])
def get_mapping_item_values(self):
return self._dict_keys(), self._dict_values()
@@ -341,8 +341,8 @@ class SequenceLiteralValue(Sequence):
'[': u'list',
'{': u'set'}
def __init__(self, infer_state, defining_value, atom):
super(SequenceLiteralValue, self).__init__(infer_state)
def __init__(self, inference_state, defining_value, atom):
super(SequenceLiteralValue, self).__init__(inference_state)
self.atom = atom
self._defining_value = defining_value
@@ -355,7 +355,7 @@ class SequenceLiteralValue(Sequence):
def py__simple_getitem__(self, index):
"""Here the index is an int/str. Raises IndexError/KeyError."""
if self.array_type == u'dict':
compiled_obj_index = compiled.create_simple_object(self.infer_state, index)
compiled_obj_index = compiled.create_simple_object(self.inference_state, index)
for key, value in self.get_tree_entries():
for k in self._defining_value.infer_node(key):
try:
@@ -471,27 +471,27 @@ class SequenceLiteralValue(Sequence):
class DictLiteralValue(_DictMixin, SequenceLiteralValue):
array_type = u'dict'
def __init__(self, infer_state, defining_value, atom):
super(SequenceLiteralValue, self).__init__(infer_state)
def __init__(self, inference_state, defining_value, atom):
super(SequenceLiteralValue, self).__init__(inference_state)
self._defining_value = defining_value
self.atom = atom
@publish_method('values')
def _imitate_values(self):
lazy_value = LazyKnownValues(self._dict_values())
return ValueSet([FakeSequence(self.infer_state, u'list', [lazy_value])])
return ValueSet([FakeSequence(self.inference_state, u'list', [lazy_value])])
@publish_method('items')
def _imitate_items(self):
lazy_values = [
LazyKnownValue(FakeSequence(
self.infer_state, u'tuple',
self.inference_state, u'tuple',
(LazyTreeValue(self._defining_value, key_node),
LazyTreeValue(self._defining_value, value_node))
)) for key_node, value_node in self.get_tree_entries()
]
return ValueSet([FakeSequence(self.infer_state, u'list', lazy_values)])
return ValueSet([FakeSequence(self.inference_state, u'list', lazy_values)])
def _dict_keys(self):
return ValueSet.from_sets(
@@ -504,19 +504,19 @@ class DictLiteralValue(_DictMixin, SequenceLiteralValue):
class _FakeArray(SequenceLiteralValue):
def __init__(self, infer_state, container, type):
super(SequenceLiteralValue, self).__init__(infer_state)
def __init__(self, inference_state, container, type):
super(SequenceLiteralValue, self).__init__(inference_state)
self.array_type = type
self.atom = container
# TODO is this class really needed?
class FakeSequence(_FakeArray):
def __init__(self, infer_state, array_type, lazy_value_list):
def __init__(self, inference_state, array_type, lazy_value_list):
"""
type should be one of "tuple", "list"
"""
super(FakeSequence, self).__init__(infer_state, None, array_type)
super(FakeSequence, self).__init__(inference_state, None, array_type)
self._lazy_value_list = lazy_value_list
def py__simple_getitem__(self, index):
@@ -538,16 +538,16 @@ class FakeSequence(_FakeArray):
class FakeDict(_DictMixin, _FakeArray):
def __init__(self, infer_state, dct):
super(FakeDict, self).__init__(infer_state, dct, u'dict')
def __init__(self, inference_state, dct):
super(FakeDict, self).__init__(inference_state, dct, u'dict')
self._dct = dct
def py__iter__(self, valueualized_node=None):
for key in self._dct:
yield LazyKnownValue(compiled.create_simple_object(self.infer_state, key))
yield LazyKnownValue(compiled.create_simple_object(self.inference_state, key))
def py__simple_getitem__(self, index):
if is_py3 and self.infer_state.environment.version_info.major == 2:
if is_py3 and self.inference_state.environment.version_info.major == 2:
# In Python 2 bytes and unicode compare.
if isinstance(index, bytes):
index_unicode = force_unicode(index)
@@ -569,7 +569,7 @@ class FakeDict(_DictMixin, _FakeArray):
@publish_method('values')
def _values(self):
return ValueSet([FakeSequence(
self.infer_state, u'tuple',
self.inference_state, u'tuple',
[LazyKnownValues(self._dict_values())]
)])
@@ -587,8 +587,8 @@ class FakeDict(_DictMixin, _FakeArray):
class MergedArray(_FakeArray):
def __init__(self, infer_state, arrays):
super(MergedArray, self).__init__(infer_state, arrays, arrays[-1].array_type)
def __init__(self, inference_state, arrays):
super(MergedArray, self).__init__(inference_state, arrays, arrays[-1].array_type)
self._arrays = arrays
def py__iter__(self, valueualized_node=None):
@@ -657,7 +657,7 @@ def check_array_additions(value, sequence):
return _check_array_additions(value, sequence)
@infer_state_method_cache(default=NO_VALUES)
@inference_state_method_cache(default=NO_VALUES)
@debug.increase_indent
def _check_array_additions(value, sequence):
"""
@@ -675,7 +675,7 @@ def _check_array_additions(value, sequence):
return NO_VALUES
def find_additions(value, arglist, add_name):
params = list(arguments.TreeArguments(value.infer_state, value, arglist).unpack())
params = list(arguments.TreeArguments(value.inference_state, value, arglist).unpack())
result = set()
if add_name in ['insert']:
params = params[1:]
@@ -719,7 +719,7 @@ def _check_array_additions(value, sequence):
random_value = value.create_value(name)
with recursion.execution_allowed(value.infer_state, power) as allowed:
with recursion.execution_allowed(value.inference_state, power) as allowed:
if allowed:
found = infer_call_of_leaf(
random_value,
@@ -758,7 +758,7 @@ class _ArrayInstance(HelperValueMixin):
self.var_args = var_args
def py__class__(self):
tuple_, = self.instance.infer_state.builtins_module.py__getattribute__('tuple')
tuple_, = self.instance.inference_state.builtins_module.py__getattribute__('tuple')
return tuple_
def py__iter__(self, valueualized_node=None):
@@ -792,7 +792,7 @@ class Slice(object):
def __getattr__(self, name):
if self._slice_object is None:
value = compiled.builtin_from_name(self._value.infer_state, 'slice')
value = compiled.builtin_from_name(self._value.inference_state, 'slice')
self._slice_object, = value.execute_with_values()
return getattr(self._slice_object, name)

View File

@@ -39,8 +39,8 @@ py__doc__() Returns the docstring for a value.
from jedi import debug
from jedi._compatibility import use_metaclass
from jedi.parser_utils import get_cached_parent_scope
from jedi.inference.cache import infer_state_method_cache, CachedMetaClass, \
infer_state_method_generator_cache
from jedi.inference.cache import inference_state_method_cache, CachedMetaClass, \
inference_state_method_generator_cache
from jedi.inference import compiled
from jedi.inference.lazy_value import LazyKnownValues
from jedi.inference.filters import ParserTreeFilter
@@ -73,7 +73,7 @@ class ClassName(TreeNameDefinition):
# We're using a different value to infer, so we cannot call super().
from jedi.inference.syntax_tree import tree_name_to_values
inferred = tree_name_to_values(
self.parent_context.infer_state, self._name_value, self.tree_name)
self.parent_context.inference_state, self._name_value, self.tree_name)
for result_value in inferred:
if self._apply_decorators:
@@ -141,10 +141,10 @@ class ClassMixin(object):
from jedi.inference.value import TreeInstance
if arguments is None:
arguments = ValuesArguments([])
return ValueSet([TreeInstance(self.infer_state, self.parent_context, self, arguments)])
return ValueSet([TreeInstance(self.inference_state, self.parent_context, self, arguments)])
def py__class__(self):
return compiled.builtin_from_name(self.infer_state, u'type')
return compiled.builtin_from_name(self.inference_state, u'type')
@property
def name(self):
@@ -159,7 +159,7 @@ class ClassMixin(object):
return list(value_.get_param_names())[1:]
return []
@infer_state_method_generator_cache()
@inference_state_method_generator_cache()
def py__mro__(self):
mro = [self]
yield self
@@ -214,7 +214,7 @@ class ClassMixin(object):
)
if not is_instance:
from jedi.inference.compiled import builtin_from_name
type_ = builtin_from_name(self.infer_state, u'type')
type_ = builtin_from_name(self.inference_state, u'type')
assert isinstance(type_, ClassValue)
if type_ != self:
for instance in type_.py__call__():
@@ -239,7 +239,7 @@ class ClassMixin(object):
class ClassValue(use_metaclass(CachedMetaClass, ClassMixin, FunctionAndClassBase)):
api_type = u'class'
@infer_state_method_cache()
@inference_state_method_cache()
def list_type_vars(self):
found = []
arglist = self.tree_node.get_super_arglist()
@@ -261,10 +261,10 @@ class ClassValue(use_metaclass(CachedMetaClass, ClassMixin, FunctionAndClassBase
arglist = self.tree_node.get_super_arglist()
if arglist:
from jedi.inference import arguments
return arguments.TreeArguments(self.infer_state, self.parent_context, arglist)
return arguments.TreeArguments(self.inference_state, self.parent_context, arglist)
return None
@infer_state_method_cache(default=())
@inference_state_method_cache(default=())
def py__bases__(self):
args = self._get_bases_arguments()
if args is not None:
@@ -273,10 +273,10 @@ class ClassValue(use_metaclass(CachedMetaClass, ClassMixin, FunctionAndClassBase
return lst
if self.py__name__() == 'object' \
and self.parent_context == self.infer_state.builtins_module:
and self.parent_context == self.inference_state.builtins_module:
return []
return [LazyKnownValues(
self.infer_state.builtins_module.py__getattribute__('object')
self.inference_state.builtins_module.py__getattribute__('object')
)]
def py__getitem__(self, index_value_set, valueualized_node):
@@ -320,7 +320,7 @@ class ClassValue(use_metaclass(CachedMetaClass, ClassMixin, FunctionAndClassBase
debug.dbg('Unprocessed metaclass %s', metaclass)
return []
@infer_state_method_cache(default=NO_VALUES)
@inference_state_method_cache(default=NO_VALUES)
def get_metaclasses(self):
args = self._get_bases_arguments()
if args is not None:

View File

@@ -2,7 +2,7 @@ import re
import os
from jedi import debug
from jedi.inference.cache import infer_state_method_cache
from jedi.inference.cache import inference_state_method_cache
from jedi.inference.names import ValueNameMixin, AbstractNameDefinition
from jedi.inference.filters import GlobalNameFilter, ParserTreeFilter, DictFilter, MergedFilter
from jedi.inference import compiled
@@ -27,13 +27,13 @@ class _ModuleAttributeName(AbstractNameDefinition):
def infer(self):
if self._string_value is not None:
s = self._string_value
if self.parent_context.infer_state.environment.version_info.major == 2 \
if self.parent_context.inference_state.environment.version_info.major == 2 \
and not isinstance(s, bytes):
s = s.encode('utf-8')
return ValueSet([
create_simple_object(self.parent_context.infer_state, s)
create_simple_object(self.parent_context.inference_state, s)
])
return compiled.get_string_value_set(self.parent_context.infer_state)
return compiled.get_string_value_set(self.parent_context.inference_state)
class ModuleName(ValueNameMixin, AbstractNameDefinition):
@@ -48,9 +48,9 @@ class ModuleName(ValueNameMixin, AbstractNameDefinition):
return self._name
def iter_module_names(infer_state, paths):
def iter_module_names(inference_state, paths):
# Python modules/packages
for n in infer_state.compiled_subprocess.list_module_names(paths):
for n in inference_state.compiled_subprocess.list_module_names(paths):
yield n
for path in paths:
@@ -75,7 +75,7 @@ def iter_module_names(infer_state, paths):
class SubModuleDictMixin(object):
@infer_state_method_cache()
@inference_state_method_cache()
def sub_modules_dict(self):
"""
Lists modules in the directory of this module (if this module is a
@@ -87,7 +87,7 @@ class SubModuleDictMixin(object):
except AttributeError:
pass
else:
mods = iter_module_names(self.infer_state, method())
mods = iter_module_names(self.inference_state, method())
for name in mods:
# It's obviously a relative import to the current module.
names[name] = SubModuleName(self, name)
@@ -113,7 +113,7 @@ class ModuleMixin(SubModuleDictMixin):
yield star_filter
def py__class__(self):
c, = values_from_qualified_names(self.infer_state, u'types', u'ModuleType')
c, = values_from_qualified_names(self.inference_state, u'types', u'ModuleType')
return c
def is_module(self):
@@ -123,7 +123,7 @@ class ModuleMixin(SubModuleDictMixin):
return False
@property
@infer_state_method_cache()
@inference_state_method_cache()
def name(self):
return ModuleName(self, self._string_name)
@@ -140,7 +140,7 @@ class ModuleMixin(SubModuleDictMixin):
# Remove PEP 3149 names
return re.sub(r'\.[a-z]+-\d{2}[mud]{0,3}$', '', r.group(1))
@infer_state_method_cache()
@inference_state_method_cache()
def _module_attributes_dict(self):
names = ['__package__', '__doc__', '__name__']
# All the additional module attributes are strings.
@@ -157,7 +157,7 @@ class ModuleMixin(SubModuleDictMixin):
# I'm not sure if the star import cache is really that effective anymore
# with all the other really fast import caches. Recheck. Also we would need
# to push the star imports into InferenceState.module_cache, if we reenable this.
@infer_state_method_cache([])
@inference_state_method_cache([])
def star_imports(self):
from jedi.inference.imports import Importer
@@ -165,7 +165,7 @@ class ModuleMixin(SubModuleDictMixin):
for i in self.tree_node.iter_imports():
if i.is_star_import():
new = Importer(
self.infer_state,
self.inference_state,
import_path=i.get_paths()[-1],
module_value=self,
level=i.level
@@ -190,9 +190,9 @@ class ModuleValue(ModuleMixin, TreeValue):
api_type = u'module'
parent_context = None
def __init__(self, infer_state, module_node, file_io, string_names, code_lines, is_package=False):
def __init__(self, inference_state, module_node, file_io, string_names, code_lines, is_package=False):
super(ModuleValue, self).__init__(
infer_state,
inference_state,
parent_context=None,
tree_node=module_node
)
@@ -242,7 +242,7 @@ class ModuleValue(ModuleMixin, TreeValue):
# It is a namespace, now try to find the rest of the
# modules on sys_path or whatever the search_path is.
paths = set()
for s in self.infer_state.get_sys_path():
for s in self.inference_state.get_sys_path():
other = os.path.join(s, self.name.string_name)
if os.path.isdir(other):
paths.add(other)

View File

@@ -1,4 +1,4 @@
from jedi.inference.cache import infer_state_method_cache
from jedi.inference.cache import inference_state_method_cache
from jedi.inference.filters import DictFilter
from jedi.inference.names import ValueNameMixin, AbstractNameDefinition
from jedi.inference.base_value import Value
@@ -25,9 +25,9 @@ class ImplicitNamespaceValue(Value, SubModuleDictMixin):
api_type = u'module'
parent_context = None
def __init__(self, infer_state, fullname, paths):
super(ImplicitNamespaceValue, self).__init__(infer_state, parent_context=None)
self.infer_state = infer_state
def __init__(self, inference_state, fullname, paths):
super(ImplicitNamespaceValue, self).__init__(inference_state, parent_context=None)
self.inference_state = inference_state
self._fullname = fullname
self._paths = paths
@@ -35,7 +35,7 @@ class ImplicitNamespaceValue(Value, SubModuleDictMixin):
yield DictFilter(self.sub_modules_dict())
@property
@infer_state_method_cache()
@inference_state_method_cache()
def name(self):
string_name = self.py__package__()[-1]
return ImplicitNSName(self, string_name)