W0235 useless-super-delegation

Message

'Useless super delegation in method %r'

Description

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.

Examples

In the following example, the method Child#method could be removed without changing the outcome.

class Parent:
    def method(self, arg):
        print(arg)

class Child(Parent):
    def method(self, arg):
        super().method(arg)
6:4: W0235: Useless super delegation in method 'method'

Pylint is pretty smart at detecting changes to behaviour, e.g. the added default for the argument:

class Parent:
    def method(self, arg):
        print(arg)

class Child(Parent):
    def method(self, arg=1):
        super().method(arg)
No issues found.

Why bother?

Useless code is bad because it increases both mental load while reading it and the cost of maintenance.

If the signature of Parent#method is changed, Child#method also needs to be changed (W0221 arguments-differ or W0222 signature-differs will be emitted if you forget).

Running Pylint locally? In your CI?

There is a better way! Run PyCodeQual & get Pylint findings with history, diffs and statistics.

Click here to find out more.