diff --git a/builtin.py b/builtin.py index 419e493f..f2d0063d 100644 --- a/builtin.py +++ b/builtin.py @@ -379,7 +379,7 @@ def parse_function_doc(func): param_str = '' if doc is not None: - r = re.search('-[>-]* ', doc[end:end+7]) + r = re.search('-[>-]* ', doc[end:end + 7]) if doc is None or r is None: ret = 'pass' else: @@ -407,12 +407,4 @@ class _Builtin(object): name = '__builtin__' _builtins = Parser(name=name) - @property - def scope(self): - return self._builtins.parser.module - - def get_defined_names(self): - return self.scope.get_defined_names() - - -Builtin = _Builtin() +builtin_scope = _Builtin()._builtins.parser.module diff --git a/evaluate.py b/evaluate.py index fd68b3f7..40279d4d 100644 --- a/evaluate.py +++ b/evaluate.py @@ -146,7 +146,7 @@ class Instance(use_metaclass(CachedMetaClass, Executable)): def __init__(self, base, var_args=parsing.Array(None, None)): super(Instance, self).__init__(base, var_args) if str(base.name) in ['list', 'set'] \ - and builtin.Builtin.scope == base.get_parent_until(): + and builtin.builtin_scope == base.get_parent_until(): # compare the module path with the builtin name. self.var_args = dynamic.check_array_instances(self) else: @@ -802,7 +802,7 @@ class Array(use_metaclass(CachedMetaClass, parsing.Base)): It returns e.g. for a list: append, pop, ... """ # `array.type` is a string with the type, e.g. 'list'. - scope = get_scopes_for_name(builtin.Builtin.scope, self._array.type)[0] + scope = get_scopes_for_name(builtin.builtin_scope, self._array.type)[0] names = scope.get_defined_names() return [ArrayElement(n) for n in names] @@ -813,7 +813,7 @@ class Array(use_metaclass(CachedMetaClass, parsing.Base)): """ Return the builtin scope as parent, because the arrays are builtins """ - return builtin.Builtin.scope + return builtin.builtin_scope def __getattr__(self, name): if name not in ['type', 'start_pos']: @@ -900,7 +900,7 @@ def get_names_for_scope(scope, position=None, star_search=True, # Add builtins to the global scope. if include_builtin: - builtin_scope = builtin.Builtin.scope + builtin_scope = builtin.builtin_scope yield builtin_scope, builtin_scope.get_defined_names() @@ -1305,7 +1305,7 @@ def follow_call_path(path, scope, position): if not isinstance(current, parsing.NamePart): if current.type in (parsing.Call.STRING, parsing.Call.NUMBER): t = type(current.name).__name__ - scopes = get_scopes_for_name(builtin.Builtin.scope, t) + scopes = get_scopes_for_name(builtin.builtin_scope, t) else: debug.warning('unknown type:', current.type, current) scopes = [] diff --git a/helpers.py b/helpers.py index fd3b29d5..1b24ac68 100644 --- a/helpers.py +++ b/helpers.py @@ -72,7 +72,7 @@ class RecursionNode(object): # The same's true for the builtins, because the builtins are really # simple. self.is_ignored = isinstance(stmt, parsing.Param) \ - or (self.script == builtin.Builtin.scope) + or (self.script == builtin.builtin_scope) def __eq__(self, other): if not other: @@ -117,7 +117,7 @@ class ExecutionRecursionDecorator(object): if isinstance(execution.base, (evaluate.Generator, evaluate.Array)): return False module = execution.get_parent_until() - if evaluate_generator or module == builtin.Builtin.scope: + if evaluate_generator or module == builtin.builtin_scope: return False if in_par_execution_funcs: