diff options
-rw-r--r-- | builder.py | 2 | ||||
-rw-r--r-- | node_classes.py | 2 | ||||
-rw-r--r-- | scoped_nodes.py | 16 | ||||
-rw-r--r-- | utils.py | 2 |
4 files changed, 9 insertions, 13 deletions
@@ -153,7 +153,7 @@ class ASTNGBuilder: """recursive method which create a partial ast from real objects (only function, class, and method are handled) """ - if self._done.has_key(obj): + if obj in self._done: return self._done[obj] self._done[obj] = node for name in dir(obj): diff --git a/node_classes.py b/node_classes.py index 50d3b120..22b033d5 100644 --- a/node_classes.py +++ b/node_classes.py @@ -69,7 +69,7 @@ def are_exclusive(stmt1, stmt2, exceptions=None): node = stmt2.parent previous = stmt2 while node: - if stmt1_parents.has_key(node): + if node in stmt1_parents: # if the common parent is a If or TryExcept statement, look if # nodes are in exclusive branches if isinstance(node, If) and exceptions is None: diff --git a/scoped_nodes.py b/scoped_nodes.py index 9238983d..91252f09 100644 --- a/scoped_nodes.py +++ b/scoped_nodes.py @@ -203,14 +203,10 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG): """ return zip(self.keys(), self.values()) - def has_key(self, name): - """method from the `dict` interface returning True if the given - name is defined in the locals dictionary - """ - return self.locals.has_key(name) - - __contains__ = has_key + def __contains__(self, name): + return name in self.locals + has_key = __contains__ # Module ##################################################################### @@ -766,7 +762,7 @@ class Class(StmtMixIn, LocalsDictNodeNG, FilterStmtsMixin): which have <name> defined in their locals """ for astng in self.ancestors(context=context): - if astng.locals.has_key(name): + if name in astng: yield astng def instance_attr_ancestors(self, name, context=None): @@ -774,7 +770,7 @@ class Class(StmtMixIn, LocalsDictNodeNG, FilterStmtsMixin): which have <name> defined in their instance attribute dictionary """ for astng in self.ancestors(context=context): - if astng.instance_attrs.has_key(name): + if name in astng.instance_attrs: yield astng def has_base(self, node): @@ -903,7 +899,7 @@ class Class(StmtMixIn, LocalsDictNodeNG, FilterStmtsMixin): done = {} for astng in chain(iter((self,)), self.ancestors()): for meth in astng.mymethods(): - if done.has_key(meth.name): + if meth.name in done: continue done[meth.name] = None yield meth @@ -303,7 +303,7 @@ class LocalsVisitor(ASTWalker): def visit(self, node): """launch the visit starting from the given node""" - if self._visited.has_key(node): + if node in self._visited: return self._visited[node] = 1 # FIXME: use set ? methods = self.get_callbacks(node) |