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):
|
||||
self.evaluator = evaluator
|
||||
self.string_name = name
|
||||
self.parent_context = evaluator.BUILTINS
|
||||
self.parent_context = evaluator.builtins_module
|
||||
|
||||
def eval(self):
|
||||
return set()
|
||||
@@ -93,7 +93,7 @@ class Keyword(object):
|
||||
def __init__(self, evaluator, name, pos):
|
||||
self.name = KeywordName(evaluator, name)
|
||||
self.start_pos = pos
|
||||
self.parent = evaluator.BUILTINS
|
||||
self.parent = evaluator.builtins_module
|
||||
|
||||
@property
|
||||
def only_valid_as_leaf(self):
|
||||
|
||||
@@ -111,12 +111,10 @@ class Evaluator(object):
|
||||
|
||||
self.reset_recursion_limitations()
|
||||
|
||||
# Constants
|
||||
# TODO move to get_builtins_module
|
||||
self.BUILTINS = compiled.get_special_object(self, 'BUILTINS')
|
||||
|
||||
def get_builtins_module(self):
|
||||
return self.BUILTINS
|
||||
@property
|
||||
@evaluator_function_cache()
|
||||
def builtins_module(self):
|
||||
return compiled.get_special_object(self, 'BUILTINS')
|
||||
|
||||
def reset_recursion_limitations(self):
|
||||
self.recursion_detector = recursion.RecursionDetector()
|
||||
|
||||
@@ -6,7 +6,7 @@ from jedi.evaluate.compiled import access
|
||||
|
||||
|
||||
def builtin_from_name(evaluator, string):
|
||||
builtins = evaluator.get_builtins_module()
|
||||
builtins = evaluator.builtins_module
|
||||
return create_from_name(evaluator, builtins, string)
|
||||
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ class CompiledObject(Context):
|
||||
try:
|
||||
# TODO wtf is this? this is exactly the same as the thing
|
||||
# below. It uses getattr as well.
|
||||
self.evaluator.BUILTINS.access_handle.getattr(name)
|
||||
self.evaluator.builtins_module.access_handle.getattr(name)
|
||||
except AttributeError:
|
||||
continue
|
||||
else:
|
||||
@@ -283,7 +283,7 @@ class EmptyCompiledName(AbstractNameDefinition):
|
||||
nothing.
|
||||
"""
|
||||
def __init__(self, evaluator, name):
|
||||
self.parent_context = evaluator.BUILTINS
|
||||
self.parent_context = evaluator.builtins_module
|
||||
self.string_name = name
|
||||
|
||||
def infer(self):
|
||||
|
||||
@@ -207,7 +207,7 @@ class CompiledInstance(AbstractInstanceContext):
|
||||
# I don't think that dynamic append lookups should happen here. That
|
||||
# sounds more like something that should go to py__iter__.
|
||||
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.
|
||||
self.var_args = iterable.get_dynamic_array_instance(self)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class AbstractIterable(Context):
|
||||
api_type = 'instance'
|
||||
|
||||
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):
|
||||
raise NotImplementedError
|
||||
@@ -86,7 +86,7 @@ class GeneratorMixin(object):
|
||||
class Generator(GeneratorMixin, Context):
|
||||
"""Handling of `yield` functions."""
|
||||
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
|
||||
|
||||
def py__iter__(self):
|
||||
@@ -212,7 +212,7 @@ class ArrayMixin(object):
|
||||
|
||||
@safe_property
|
||||
def parent(self):
|
||||
return self.evaluator.BUILTINS
|
||||
return self.evaluator.builtins_module
|
||||
|
||||
def dict_values(self):
|
||||
return ContextSet.from_sets(
|
||||
@@ -658,7 +658,7 @@ class Slice(Context):
|
||||
def __init__(self, context, start, stop, step):
|
||||
super(Slice, self).__init__(
|
||||
context.evaluator,
|
||||
parent_context=context.evaluator.BUILTINS
|
||||
parent_context=context.evaluator.builtins_module
|
||||
)
|
||||
self._context = context
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
@@ -113,7 +113,7 @@ class ExecutionRecursionDetector(object):
|
||||
self._parent_execution_funcs.append(funcdef)
|
||||
|
||||
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
|
||||
# like crazy. Therefore we just let them execute always, because
|
||||
# they usually just help a lot with getting good results.
|
||||
|
||||
@@ -57,7 +57,7 @@ def execute(evaluator, obj, arguments):
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
if obj.parent_context == evaluator.BUILTINS:
|
||||
if obj.parent_context == evaluator.builtins_module:
|
||||
module_name = 'builtins'
|
||||
elif isinstance(obj.parent_context, ModuleContext):
|
||||
module_name = obj.parent_context.name.string_name
|
||||
@@ -210,7 +210,7 @@ def builtins_reversed(evaluator, sequences, obj, arguments):
|
||||
# just returned the result directly.
|
||||
seq = iterable.FakeSequence(evaluator, 'list', rev)
|
||||
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)
|
||||
@@ -233,7 +233,7 @@ def builtins_isinstance(evaluator, objects, types, arguments):
|
||||
if cls_or_tup.is_class():
|
||||
bool_results.add(cls_or_tup in mro)
|
||||
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.
|
||||
classes = ContextSet.from_sets(
|
||||
lazy_context.infer()
|
||||
|
||||
@@ -221,7 +221,7 @@ def eval_atom(context, atom):
|
||||
@_limit_context_infers
|
||||
def eval_expr_stmt(context, stmt, seek_name=None):
|
||||
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 NO_CONTEXTS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user