7class TemplateError(Exception):
8 """Baseclass for all template errors."""
9
10 def __init__(self, message: t.Optional[str] = None) -> None: 11 super().__init__(message)
12
13 @property
Any method in a child class which is only calling the overridden method of any of its base class using super
and doing nothing else is unnecessary.
If the method isn't present in the child class, Python implicitly looks for the method in its base classes.
This issue is valid only if the method in the child class and the method in the base class has the same signature.
class Egg:
def __init__(self, first, second):
pass
class Spam(Egg):
def __init__(self, first, second):
super().__init__(first, second)
def __repr__(self):
return f'Spam({first}, {second})'
class UselessSuper:
def useless(self, first, *, second=None, **kwargs):
super().useless(first, second=second, **kwargs)
class Egg:
def __init__(self, first, second):
pass
class Spam(Egg):
# `__init__` method removed entirely
def __repr__(self):
return f'Spam({first}, {second})'
class UselessSuper:
...