forked from VimPlug/jedi
Use builtins_module instead of BUILTINS
This commit is contained in:
@@ -78,7 +78,7 @@ class KeywordName(AbstractNameDefinition):
|
|||||||
def __init__(self, evaluator, name):
|
def __init__(self, evaluator, name):
|
||||||
self.evaluator = evaluator
|
self.evaluator = evaluator
|
||||||
self.string_name = name
|
self.string_name = name
|
||||||
self.parent_context = evaluator.BUILTINS
|
self.parent_context = evaluator.builtins_module
|
||||||
|
|
||||||
def eval(self):
|
def eval(self):
|
||||||
return set()
|
return set()
|
||||||
@@ -93,7 +93,7 @@ class Keyword(object):
|
|||||||
def __init__(self, evaluator, name, pos):
|
def __init__(self, evaluator, name, pos):
|
||||||
self.name = KeywordName(evaluator, name)
|
self.name = KeywordName(evaluator, name)
|
||||||
self.start_pos = pos
|
self.start_pos = pos
|
||||||
self.parent = evaluator.BUILTINS
|
self.parent = evaluator.builtins_module
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def only_valid_as_leaf(self):
|
def only_valid_as_leaf(self):
|
||||||
|
|||||||
@@ -111,12 +111,10 @@ class Evaluator(object):
|
|||||||
|
|
||||||
self.reset_recursion_limitations()
|
self.reset_recursion_limitations()
|
||||||
|
|
||||||
# Constants
|
@property
|
||||||
# TODO move to get_builtins_module
|
@evaluator_function_cache()
|
||||||
self.BUILTINS = compiled.get_special_object(self, 'BUILTINS')
|
def builtins_module(self):
|
||||||
|
return compiled.get_special_object(self, 'BUILTINS')
|
||||||
def get_builtins_module(self):
|
|
||||||
return self.BUILTINS
|
|
||||||
|
|
||||||
def reset_recursion_limitations(self):
|
def reset_recursion_limitations(self):
|
||||||
self.recursion_detector = recursion.RecursionDetector()
|
self.recursion_detector = recursion.RecursionDetector()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from jedi.evaluate.compiled import access
|
|||||||
|
|
||||||
|
|
||||||
def builtin_from_name(evaluator, string):
|
def builtin_from_name(evaluator, string):
|
||||||
builtins = evaluator.get_builtins_module()
|
builtins = evaluator.builtins_module
|
||||||
return create_from_name(evaluator, builtins, string)
|
return create_from_name(evaluator, builtins, string)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class CompiledObject(Context):
|
|||||||
try:
|
try:
|
||||||
# TODO wtf is this? this is exactly the same as the thing
|
# TODO wtf is this? this is exactly the same as the thing
|
||||||
# below. It uses getattr as well.
|
# below. It uses getattr as well.
|
||||||
self.evaluator.BUILTINS.access_handle.getattr(name)
|
self.evaluator.builtins_module.access_handle.getattr(name)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@@ -283,7 +283,7 @@ class EmptyCompiledName(AbstractNameDefinition):
|
|||||||
nothing.
|
nothing.
|
||||||
"""
|
"""
|
||||||
def __init__(self, evaluator, name):
|
def __init__(self, evaluator, name):
|
||||||
self.parent_context = evaluator.BUILTINS
|
self.parent_context = evaluator.builtins_module
|
||||||
self.string_name = name
|
self.string_name = name
|
||||||
|
|
||||||
def infer(self):
|
def infer(self):
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ class CompiledInstance(AbstractInstanceContext):
|
|||||||
# I don't think that dynamic append lookups should happen here. That
|
# I don't think that dynamic append lookups should happen here. That
|
||||||
# sounds more like something that should go to py__iter__.
|
# sounds more like something that should go to py__iter__.
|
||||||
if self.class_context.name.string_name in ['list', 'set'] \
|
if self.class_context.name.string_name in ['list', 'set'] \
|
||||||
and self.parent_context.get_root_context() == self.evaluator.BUILTINS:
|
and self.parent_context.get_root_context() == self.evaluator.builtins_module:
|
||||||
# compare the module path with the builtin name.
|
# compare the module path with the builtin name.
|
||||||
self.var_args = iterable.get_dynamic_array_instance(self)
|
self.var_args = iterable.get_dynamic_array_instance(self)
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class AbstractIterable(Context):
|
|||||||
api_type = 'instance'
|
api_type = 'instance'
|
||||||
|
|
||||||
def __init__(self, evaluator):
|
def __init__(self, evaluator):
|
||||||
super(AbstractIterable, self).__init__(evaluator, evaluator.BUILTINS)
|
super(AbstractIterable, self).__init__(evaluator, evaluator.builtins_module)
|
||||||
|
|
||||||
def get_filters(self, search_global, until_position=None, origin_scope=None):
|
def get_filters(self, search_global, until_position=None, origin_scope=None):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@@ -86,7 +86,7 @@ class GeneratorMixin(object):
|
|||||||
class Generator(GeneratorMixin, Context):
|
class Generator(GeneratorMixin, Context):
|
||||||
"""Handling of `yield` functions."""
|
"""Handling of `yield` functions."""
|
||||||
def __init__(self, evaluator, func_execution_context):
|
def __init__(self, evaluator, func_execution_context):
|
||||||
super(Generator, self).__init__(evaluator, parent_context=evaluator.BUILTINS)
|
super(Generator, self).__init__(evaluator, parent_context=evaluator.builtins_module)
|
||||||
self._func_execution_context = func_execution_context
|
self._func_execution_context = func_execution_context
|
||||||
|
|
||||||
def py__iter__(self):
|
def py__iter__(self):
|
||||||
@@ -212,7 +212,7 @@ class ArrayMixin(object):
|
|||||||
|
|
||||||
@safe_property
|
@safe_property
|
||||||
def parent(self):
|
def parent(self):
|
||||||
return self.evaluator.BUILTINS
|
return self.evaluator.builtins_module
|
||||||
|
|
||||||
def dict_values(self):
|
def dict_values(self):
|
||||||
return ContextSet.from_sets(
|
return ContextSet.from_sets(
|
||||||
@@ -658,7 +658,7 @@ class Slice(Context):
|
|||||||
def __init__(self, context, start, stop, step):
|
def __init__(self, context, start, stop, step):
|
||||||
super(Slice, self).__init__(
|
super(Slice, self).__init__(
|
||||||
context.evaluator,
|
context.evaluator,
|
||||||
parent_context=context.evaluator.BUILTINS
|
parent_context=context.evaluator.builtins_module
|
||||||
)
|
)
|
||||||
self._context = context
|
self._context = context
|
||||||
# all of them are either a Precedence or None.
|
# all of them are either a Precedence or None.
|
||||||
|
|||||||
@@ -430,5 +430,5 @@ def get_global_filters(evaluator, context, until_position, origin_scope):
|
|||||||
context = context.parent_context
|
context = context.parent_context
|
||||||
|
|
||||||
# Add builtins to the global scope.
|
# Add builtins to the global scope.
|
||||||
for filter in evaluator.BUILTINS.get_filters(search_global=True):
|
for filter in evaluator.builtins_module.get_filters(search_global=True):
|
||||||
yield filter
|
yield filter
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ class ExecutionRecursionDetector(object):
|
|||||||
self._parent_execution_funcs.append(funcdef)
|
self._parent_execution_funcs.append(funcdef)
|
||||||
|
|
||||||
module = execution.get_root_context()
|
module = execution.get_root_context()
|
||||||
if module == self._evaluator.BUILTINS:
|
if module == self._evaluator.builtins_module:
|
||||||
# We have control over builtins so we know they are not recursing
|
# We have control over builtins so we know they are not recursing
|
||||||
# like crazy. Therefore we just let them execute always, because
|
# like crazy. Therefore we just let them execute always, because
|
||||||
# they usually just help a lot with getting good results.
|
# they usually just help a lot with getting good results.
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ def execute(evaluator, obj, arguments):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if obj.parent_context == evaluator.BUILTINS:
|
if obj.parent_context == evaluator.builtins_module:
|
||||||
module_name = 'builtins'
|
module_name = 'builtins'
|
||||||
elif isinstance(obj.parent_context, ModuleContext):
|
elif isinstance(obj.parent_context, ModuleContext):
|
||||||
module_name = obj.parent_context.name.string_name
|
module_name = obj.parent_context.name.string_name
|
||||||
@@ -210,7 +210,7 @@ def builtins_reversed(evaluator, sequences, obj, arguments):
|
|||||||
# just returned the result directly.
|
# just returned the result directly.
|
||||||
seq = iterable.FakeSequence(evaluator, 'list', rev)
|
seq = iterable.FakeSequence(evaluator, 'list', rev)
|
||||||
arguments = ValuesArguments([ContextSet(seq)])
|
arguments = ValuesArguments([ContextSet(seq)])
|
||||||
return ContextSet(CompiledInstance(evaluator, evaluator.BUILTINS, obj, arguments))
|
return ContextSet(CompiledInstance(evaluator, evaluator.builtins_module, obj, arguments))
|
||||||
|
|
||||||
|
|
||||||
@argument_clinic('obj, type, /', want_arguments=True)
|
@argument_clinic('obj, type, /', want_arguments=True)
|
||||||
@@ -233,7 +233,7 @@ def builtins_isinstance(evaluator, objects, types, arguments):
|
|||||||
if cls_or_tup.is_class():
|
if cls_or_tup.is_class():
|
||||||
bool_results.add(cls_or_tup in mro)
|
bool_results.add(cls_or_tup in mro)
|
||||||
elif cls_or_tup.name.string_name == 'tuple' \
|
elif cls_or_tup.name.string_name == 'tuple' \
|
||||||
and cls_or_tup.get_root_context() == evaluator.BUILTINS:
|
and cls_or_tup.get_root_context() == evaluator.builtins_module:
|
||||||
# Check for tuples.
|
# Check for tuples.
|
||||||
classes = ContextSet.from_sets(
|
classes = ContextSet.from_sets(
|
||||||
lazy_context.infer()
|
lazy_context.infer()
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ def eval_atom(context, atom):
|
|||||||
@_limit_context_infers
|
@_limit_context_infers
|
||||||
def eval_expr_stmt(context, stmt, seek_name=None):
|
def eval_expr_stmt(context, stmt, seek_name=None):
|
||||||
with recursion.execution_allowed(context.evaluator, stmt) as allowed:
|
with recursion.execution_allowed(context.evaluator, stmt) as allowed:
|
||||||
if allowed or context.get_root_context() == context.evaluator.BUILTINS:
|
if allowed or context.get_root_context() == context.evaluator.builtins_module:
|
||||||
return _eval_expr_stmt(context, stmt, seek_name)
|
return _eval_expr_stmt(context, stmt, seek_name)
|
||||||
return NO_CONTEXTS
|
return NO_CONTEXTS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user