diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-12-06 14:54:52 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-12-06 14:54:52 +0200 |
commit | 46af05ffc1b443290451e19d0a0ca0148e1b2a00 (patch) | |
tree | 6fa87656daa3334036bcefba562080df893f8959 /pylint | |
parent | e54a5ec5bf41840de96df649e62e9b2fac316fa7 (diff) | |
download | pylint-46af05ffc1b443290451e19d0a0ca0148e1b2a00.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.
Diffstat (limited to 'pylint')
-rw-r--r-- | pylint/checkers/newstyle.py | 14 | ||||
-rw-r--r-- | pylint/test/functional/super_checks.py | 2 | ||||
-rw-r--r-- | pylint/test/functional/super_checks.txt | 27 |
3 files changed, 20 insertions, 23 deletions
diff --git a/pylint/checkers/newstyle.py b/pylint/checkers/newstyle.py index 489c22f..5cc8f13 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 14fd5a2..f4aec0a 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 a98a25b..ea1d67b 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 |