Commits

Boris FELD committed 1a27a3d

Fix false positive W0231 for missing call to object.__init__. Closes #103656

Comments (0)

Files changed (3)

     * #100654: fix grammatical error for W0332 message (using 'l' as
       long int identifier)
 
+    * #103656: fix W0231 false positive for missing call to object.__init__
+      (patch by lothiraldan@gmail.com)
+
     * fix cross-interpreter issue (non compatible access to __builtins__)
 
     * stop including tests files in distribution, they causes crash when
       installed with python3 (#72022, #82417, #76910)
 
-
 2012-07-17  --  0.25.2
     * #93591: Correctly emit warnings about clobbered variable names when an
       except handler contains a tuple of names instead of a single name.

checkers/classes.py

                         self.add_message('W0233', node=expr, args=klass.name)
             except astng.InferenceError:
                 continue
-        for klass in not_called_yet.keys():
-            if klass.name == 'object':
+        for klass, method in not_called_yet.iteritems():
+            if klass.name == 'object' or method.parent.name == 'object':
                 continue
             self.add_message('W0231', args=klass.name, node=node)
 
     to_call = {}
     for base_node in klass_node.ancestors(recurs=False):
         try:
-            base_node.local_attr(method)
-            to_call[base_node] = 1
+            to_call[base_node] = base_node.local_attr(method)[-1]
         except astng.NotFoundError:
             continue
     return to_call

test/input/func_w0231.py

     """derived new style class"""
     def __init__(self):
         super(NewStyleB, self).__init__()
+
+
+class NoInit(object):
+    """No __init__ defined"""
+
+class Init(NoInit):
+    """Don't complain for not calling the super __init__"""
+
+    def __init__(self, arg):
+        self.arg = arg