Unnecessary arguments in super call

It's unnecessary to use arguments when calling super for the parent class.

Explicitly passing in both the class and instance breaks the DRY (Don't Repeat Yourself) rule. This make the code brittle with regards to changing the class name, and is often considered inelegant by many.

As of Python 3, there is no need to explicitly specify the class name and instance when calling super(). If they are not provided, Python will default to the current class and the current instance.

Python 2.7 required specifying arguments, but note that Python 2.7 has already reached "End Of Life" and is no longer supported by the Python Software Foundation. For this reason your code might not need to support Python 2.7 either.

Moreover, it takes more than specifying arguments in super to make your codebase backwards compatible with Python 2.7: you must not use any new feature of Python 3...ever. That's some serious dedication to a dead language.

Given that these two are completely equivalent:

Why not choose the easiest to both read and write (the first one)?

If our GitHub code review bot spots this issue in your pull request it gives this advice:

code-review-doctorbotsuggested changes just now
helpers.py
1
+
class FooBarClass(Bar):
2
+
    def foo(self, bar):
3
+
        super(Foo, self).foo(bar)
Suggested changes
-
        super(Foo, self).foo(bar)
+
        super().foo(bar)
Commit suggestion

It's unnecessary to use arguments when calling super for the parent class.

Read more
Update helpers.py
We're your Python code review copilot. Get code improvements right in your pull request with our GitHub code review bot.

Configuring this check

Code Review Doctor will run this check by default. No configuration is needed but the check can be turned on/off using check code redundant-super-args in your pyproject.toml file.

Read more about configuring Code Review Doctor.