diff options
| -rw-r--r-- | node_classes.py | 10 | ||||
| -rw-r--r-- | nodes.py | 4 | ||||
| -rw-r--r-- | scoped_nodes.py | 22 |
3 files changed, 20 insertions, 16 deletions
diff --git a/node_classes.py b/node_classes.py index b3fc1871..f93ad4a8 100644 --- a/node_classes.py +++ b/node_classes.py @@ -93,9 +93,6 @@ def are_exclusive(stmt1, stmt2, exceptions=None): return False - - - class LookupMixIn(BaseClass): """Mixin looking up a name in the right scope """ @@ -659,13 +656,6 @@ class List(NodeNG, Instance, ParentAssignTypeMixin): -class ListComp(NodeNG): - """class representing a ListComp node""" - _astng_fields = ('elt', 'generators') - elt = None - generators = None - - class Pass(StmtMixIn, NodeNG): """class representing a Pass node""" @@ -56,11 +56,11 @@ from logilab.astng.node_classes import Arguments, AssAttr, Assert, Assign, \ Comprehension, Const, Continue, Decorators, DelAttr, DelName, Delete, \ Dict, Discard, Ellipsis, EmptyNode, ExceptHandler, Exec, ExtSlice, For, \ From, Getattr, Global, If, IfExp, Import, Index, Keyword, \ - List, ListComp, Name, Pass, Print, Raise, Return, Set, Slice, Subscript, \ + List, Name, Pass, Print, Raise, Return, Set, Slice, Subscript, \ TryExcept, TryFinally, Tuple, UnaryOp, While, With, Yield, \ const_factory from logilab.astng.scoped_nodes import Module, GenExpr, Lambda, DictComp, \ - SetComp, Function, Class + ListComp, SetComp, Function, Class ALL_NODE_CLASSES = ( Arguments, AssAttr, Assert, Assign, AssName, AugAssign, diff --git a/scoped_nodes.py b/scoped_nodes.py index 82ad344a..86973897 100644 --- a/scoped_nodes.py +++ b/scoped_nodes.py @@ -400,14 +400,14 @@ class Module(LocalsDictNodeNG): return [name for name in self.keys() if not name.startswith('_')] -class ScopedComprehensionNodeNG(LocalsDictNodeNG): +class ComprehensionScope(LocalsDictNodeNG): def frame(self): return self.parent.frame() scope_lookup = LocalsDictNodeNG._scope_lookup -class GenExpr(ScopedComprehensionNodeNG): +class GenExpr(ComprehensionScope): _astng_fields = ('elt', 'generators') def __init__(self): @@ -416,7 +416,7 @@ class GenExpr(ScopedComprehensionNodeNG): self.generators = [] -class DictComp(ScopedComprehensionNodeNG): +class DictComp(ComprehensionScope): _astng_fields = ('key', 'value', 'generators') def __init__(self): @@ -426,7 +426,7 @@ class DictComp(ScopedComprehensionNodeNG): self.generators = [] -class SetComp(ScopedComprehensionNodeNG): +class SetComp(ComprehensionScope): _astng_fields = ('elt', 'generators') def __init__(self): @@ -435,6 +435,20 @@ class SetComp(ScopedComprehensionNodeNG): self.generators = [] +class _ListComp(NodeNG): + """class representing a ListComp node""" + _astng_fields = ('elt', 'generators') + elt = None + generators = None + +if sys.version_info >= (3, 0): + class ListComp(_ListComp, ComprehensionScope): + """class representing a ListComp node""" + def __init__(self): + self.locals = {} +else: + class ListComp(_ListComp): + """class representing a ListComp node""" # Function ################################################################### |
