As Mathieu mentioned, you don't need to override __init__
in SpecificError
since you are only calling super()
.
class MyProjectExceptions(Exception):
"""The base class for all my project's exceptions."""
def __init__(self, message, func):
super(MyProjectExceptions, self).__init__(message) # Normal exception handling
self.func = func # Error origin for logging
class SpecificError(MyProjectExceptions):
"""Raise when a specific error occurs."""
Pylint's developers explain useless-super-delegation
in a bit more depth on the Pylint changelog:
useless-super-delegation
[is] used whenever we can detect that an
overridden method is useless, relying on super()
delegation to do the
same thing as another method from the MRO.
For instance, in this example, the first two methods are useless,
since they do the exact same thing as the methods from the base
classes, while the next two methods are not, since they do some extra
operations with the passed arguments.
class Impl(Base):
def __init__(self, param1, param2):
super(Impl, self).__init__(param1, param2)
def useless(self, first, second):
return super(Impl, self).useless(first, second)
def not_useless(self, first, **kwargs):
debug = kwargs.pop('debug', False)
if debug:
...
return super(Impl, self).not_useless(first, **kwargs)
def not_useless_1(self, first, *args):
return super(Impl, self).not_useless_1(first + some_value, *args)
What's New In Pylint 1.7
The warning's creator further explains in a commit message:
This is used whenever pylint can detect than an overridden method is
useless, relying on super()
delegation to implement the same thing as
another method from MRO. In this case, it is enough to not implement
the given method and let it be propagated to the another implementation
from the MRO.
For the original issue report, see #839 - Pylint rule against people overriding a method just to call super.