Replace some isinstance checks in the parser tree with .type checks.

This commit is contained in:
Dave Halter
2015-02-09 12:27:29 +01:00
parent a9a3387cb0
commit a095f8d9e0
4 changed files with 17 additions and 13 deletions
+1 -1
View File
@@ -156,7 +156,7 @@ def get_module_names(module, all_scopes):
return chain.from_iterable(dct.values())
class FakeImport(pr.Import):
class FakeImport(pr.ImportName):
def __init__(self, name, parent, level=0):
super(FakeImport, self).__init__([])
self.parent = parent
+3 -1
View File
@@ -565,6 +565,8 @@ class FunctionExecution(Executed):
multiple calls to functions and recursion has to be avoided. But this is
responsibility of the decorators.
"""
type = 'funcdef'
def __init__(self, evaluator, base, *args, **kwargs):
super(FunctionExecution, self).__init__(evaluator, base, *args, **kwargs)
# for deep_ast_copy
@@ -646,7 +648,7 @@ class FunctionExecution(Executed):
return objects
def __getattr__(self, name):
if name not in ['start_pos', 'end_pos', 'imports', '_sub_module', 'type']:
if name not in ['start_pos', 'end_pos', 'imports', 'name', 'type']:
raise AttributeError('Tried to access %s: %s. Why?' % (name, self))
return getattr(self.base, name)