summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-12-06 14:54:52 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-12-06 14:54:52 +0200
commit81acc57094ccab24575c4308d0fad2193081998a (patch)
tree7e0a60941b31f0b35073bcf679244031a9954e76
parent70b80bd1f4bfa61823d8ea2ace16fc9bcf132281 (diff)
downloadpylint-git-81acc57094ccab24575c4308d0fad2193081998a.tar.gz
Don't emit super-on-old-class on classes with unknown bases.
The change also removes the confidence handling for super-on-old-class, which isn't used enough to merit its existence. Closes issue #721.
-rw-r--r--ChangeLog3
-rw-r--r--pylint/checkers/newstyle.py14
-rw-r--r--pylint/test/functional/super_checks.py2
-rw-r--r--pylint/test/functional/super_checks.txt27
4 files changed, 23 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index d2bbdee60..7c2ea9343 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@ ChangeLog for Pylint
This prevents a crash which can occur when an object doesn't have
.qname() method after the inference.
+ * Don't emit super-on-old-class on classes with unknown bases.
+ Closes issue #721.
+
2015-12-02 -- 1.5.1
diff --git a/pylint/checkers/newstyle.py b/pylint/checkers/newstyle.py
index 489c22fe9..5cc8f13c3 100644
--- a/pylint/checkers/newstyle.py
+++ b/pylint/checkers/newstyle.py
@@ -128,12 +128,10 @@ class NewStyleConflictChecker(BaseChecker):
isinstance(call.func, astroid.Name) and
call.func.name == 'super'):
continue
- confidence = (INFERENCE if has_known_bases(klass)
- else INFERENCE_FAILURE)
- if not klass.newstyle:
+
+ if not klass.newstyle and has_known_bases(klass):
# super should not be used on an old style class
- self.add_message('super-on-old-class', node=node,
- confidence=confidence)
+ self.add_message('super-on-old-class', node=node)
else:
# super first arg should be the class
if not call.args and sys.version_info[0] == 3:
@@ -147,8 +145,7 @@ class NewStyleConflictChecker(BaseChecker):
continue
if supcls is None:
- self.add_message('missing-super-argument', node=call,
- confidence=confidence)
+ self.add_message('missing-super-argument', node=call)
continue
if klass is not supcls:
@@ -162,8 +159,7 @@ class NewStyleConflictChecker(BaseChecker):
if hasattr(call.args[0], 'name'):
name = call.args[0].name
if name is not None:
- self.add_message('bad-super-call', node=call, args=(name, ),
- confidence=confidence)
+ self.add_message('bad-super-call', node=call, args=(name, ))
def register(linter):
diff --git a/pylint/test/functional/super_checks.py b/pylint/test/functional/super_checks.py
index 14fd5a2d9..f4aec0acd 100644
--- a/pylint/test/functional/super_checks.py
+++ b/pylint/test/functional/super_checks.py
@@ -65,9 +65,9 @@ class SuperDifferentScope(object):
class UnknownBases(Missing):
"""Don't emit if we don't know all the bases."""
def __init__(self):
- # pylint: disable=super-on-old-class
super(UnknownBases, self).__init__()
super(UnknownBases, self).test()
+ super(Missing, self).test() # [bad-super-call]
# Test that we are detecting proper super errors.
diff --git a/pylint/test/functional/super_checks.txt b/pylint/test/functional/super_checks.txt
index a98a25b2d..ea1d67be7 100644
--- a/pylint/test/functional/super_checks.txt
+++ b/pylint/test/functional/super_checks.txt
@@ -1,18 +1,19 @@
old-style-class:6:Aaaa:Old-style class defined.
-super-on-old-class:8:Aaaa.hop:Use of super on an old style class:INFERENCE
+super-on-old-class:8:Aaaa.hop:Use of super on an old style class
no-member:10:Aaaa.hop:Super of 'Aaaa' has no 'hop' member:INFERENCE
-super-on-old-class:12:Aaaa.__init__:Use of super on an old style class:INFERENCE
+super-on-old-class:12:Aaaa.__init__:Use of super on an old style class
no-member:19:NewAaaa.hop:Super of 'NewAaaa' has no 'hop' member:INFERENCE
-bad-super-call:22:NewAaaa.__init__:Bad first argument 'Aaaa' given to super():INFERENCE
-missing-super-argument:27:Py3kAaaa.__init__:Missing argument to super():INFERENCE
-bad-super-call:32:Py3kWrongSuper.__init__:Bad first argument 'NewAaaa' given to super():INFERENCE
-bad-super-call:37:WrongNameRegression.__init__:Bad first argument 'Missing' given to super():INFERENCE
-bad-super-call:46:CrashSuper.__init__:Bad first argument 'NewAaaa' given to super():INFERENCE
-bad-super-call:62:SuperDifferentScope.test:Bad first argument 'object' given to super():INFERENCE
-not-callable:89:InvalidSuperChecks.__init__:super(InvalidSuperChecks, self).not_a_method is not callable:HIGH
+bad-super-call:22:NewAaaa.__init__:Bad first argument 'Aaaa' given to super()
+missing-super-argument:27:Py3kAaaa.__init__:Missing argument to super()
+bad-super-call:32:Py3kWrongSuper.__init__:Bad first argument 'NewAaaa' given to super()
+bad-super-call:37:WrongNameRegression.__init__:Bad first argument 'Missing' given to super()
+bad-super-call:46:CrashSuper.__init__:Bad first argument 'NewAaaa' given to super()
+bad-super-call:62:SuperDifferentScope.test:Bad first argument 'object' given to super()
+bad-super-call:70:UnknownBases.__init__:Bad first argument 'Missing' given to super()
+not-callable:89:InvalidSuperChecks.__init__:super(InvalidSuperChecks, self).not_a_method is not callable
no-member:90:InvalidSuperChecks.__init__:Super of 'InvalidSuperChecks' has no 'attribute_error' member:INFERENCE
-no-value-for-parameter:92:InvalidSuperChecks.__init__:No value for argument 'param' in method call:HIGH
-too-many-function-args:93:InvalidSuperChecks.__init__:Too many positional arguments for method call:HIGH
-no-value-for-parameter:95:InvalidSuperChecks.__init__:No value for argument 'param' in method call:HIGH
-unexpected-keyword-arg:95:InvalidSuperChecks.__init__:Unexpected keyword argument 'lala' in method call:HIGH
+no-value-for-parameter:92:InvalidSuperChecks.__init__:No value for argument 'param' in method call
+too-many-function-args:93:InvalidSuperChecks.__init__:Too many positional arguments for method call
+no-value-for-parameter:95:InvalidSuperChecks.__init__:No value for argument 'param' in method call
+unexpected-keyword-arg:95:InvalidSuperChecks.__init__:Unexpected keyword argument 'lala' in method call
no-member:98:InvalidSuperChecks.__init__:Super of 'InvalidSuperChecks' has no 'attribute_error' member:INFERENCE \ No newline at end of file