diff options
-rw-r--r-- | checkers/classes.py | 8 | ||||
-rw-r--r-- | test/input/func_w0233.py | 8 |
2 files changed, 13 insertions, 3 deletions
diff --git a/checkers/classes.py b/checkers/classes.py index eb306d5..0609d17 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -433,6 +433,7 @@ instance attributes.'} """ klass_node = node.parent.frame() to_call = _ancestors_to_call(klass_node) + not_called_yet = dict(to_call) for stmt in node.nodes_of_class(astng.CallFunc): expr = stmt.func if not isinstance(expr, astng.Getattr) \ @@ -448,12 +449,13 @@ instance attributes.'} if klass is YES: continue try: - del to_call[klass] + del not_called_yet[klass] except KeyError: - self.add_message('W0233', node=expr, args=klass.name) + if klass not in to_call: + self.add_message('W0233', node=expr, args=klass.name) except astng.InferenceError: continue - for klass in to_call.keys(): + for klass in not_called_yet.keys(): if klass.name == 'object': continue self.add_message('W0231', args=klass.name, node=node) diff --git a/test/input/func_w0233.py b/test/input/func_w0233.py index a667010..3400438 100644 --- a/test/input/func_w0233.py +++ b/test/input/func_w0233.py @@ -26,3 +26,11 @@ class CCC(BBBBMixin, func_w0233.AAAA, func_w0233.BBBB, nonexistant.AClass): func_w0233.AAAA.__init__(self) func_w0233.BBBB.__init__(self) nonexistant.AClass.__init__(self) + +class DDDD(AAAA): + """call superclass constructor in disjunct branches""" + def __init__(self, value): + if value: + AAAA.__init__(self) + else: + AAAA.__init__(self) |