summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFELD Boris <lothiraldan@gmail.com>2012-09-19 14:53:01 +0200
committerFELD Boris <lothiraldan@gmail.com>2012-09-19 14:53:01 +0200
commit31b1088b7d9a00de4078cf44d3af9bbb29bfaa05 (patch)
tree05f375db3b051011839dc94385c8322098484f77
parent2c2d985aab13c3359c72fb04172ebe8e9a23e776 (diff)
downloadpylint-git-31b1088b7d9a00de4078cf44d3af9bbb29bfaa05.tar.gz
Fix false positive W0231 for missing call to object.__init__. Closes #103656
-rw-r--r--ChangeLog4
-rw-r--r--checkers/classes.py7
-rw-r--r--test/input/func_w0231.py10
3 files changed, 16 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index d23d5b60f..ab37974c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,12 +14,14 @@ ChangeLog for PyLint
* #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.
diff --git a/checkers/classes.py b/checkers/classes.py
index 5a2a57300..9e26edc77 100644
--- a/checkers/classes.py
+++ b/checkers/classes.py
@@ -575,8 +575,8 @@ a metaclass class method.'}
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)
@@ -616,8 +616,7 @@ def _ancestors_to_call(klass_node, method='__init__'):
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
diff --git a/test/input/func_w0231.py b/test/input/func_w0231.py
index ddebae178..934238019 100644
--- a/test/input/func_w0231.py
+++ b/test/input/func_w0231.py
@@ -36,3 +36,13 @@ class NewStyleB(NewStyleA):
"""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