diff options
author | Rene Zhang <rz99@cornell.edu> | 2015-08-26 12:49:54 -0400 |
---|---|---|
committer | Rene Zhang <rz99@cornell.edu> | 2015-08-26 12:49:54 -0400 |
commit | aa8d2102ee005015f8c20904e92c77c1f607bd5b (patch) | |
tree | c1b91ddf8a0e0a0288afff65d05e7ff7077e52ec /astroid/scoped_nodes.py | |
parent | e40a3cf3530d5b360ef09ac129805f1521cdc64d (diff) | |
download | astroid-aa8d2102ee005015f8c20904e92c77c1f607bd5b.tar.gz |
Add new _find_metaclass method to maintain signature of metaclass
Diffstat (limited to 'astroid/scoped_nodes.py')
-rw-r--r-- | astroid/scoped_nodes.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/astroid/scoped_nodes.py b/astroid/scoped_nodes.py index e2ebb4a..efa20cb 100644 --- a/astroid/scoped_nodes.py +++ b/astroid/scoped_nodes.py @@ -1469,13 +1469,7 @@ class Class(bases.Statement, LocalsDictNodeNG, mixins.FilterStmtsMixin): return None return infered - def metaclass(self, seen=None): - """Return the metaclass of this class. - - If this class does not define explicitly a metaclass, - then the first defined metaclass in ancestors will be used - instead. - """ + def _find_metaclass(self, seen): if seen is None: seen = set() seen.add(self) @@ -1484,11 +1478,20 @@ class Class(bases.Statement, LocalsDictNodeNG, mixins.FilterStmtsMixin): if klass is None: for parent in self.ancestors(): if parent not in seen: - klass = parent.metaclass(seen=seen) + klass = parent._find_metaclass(seen) if klass is not None: break return klass + def metaclass(self): + """Return the metaclass of this class. + + If this class does not define explicitly a metaclass, + then the first defined metaclass in ancestors will be used + instead. + """ + return self._find_metaclass(None) + def has_metaclass_hack(self): return self._metaclass_hack |