NoRedundantArgumentsSuperRule
Remove redundant arguments when using super for readability.
Message
Do not use arguments when calling super for the parent class. See https://www.python.org/dev/peps/pep-3135/
Has Autofix: Yes
VALID Code Examples
# 1:
class Foo(Bar):
def foo(self, bar):
super().foo(bar)
# 2:
class Foo(Bar):
def foo(self, bar):
super(Bar, self).foo(bar)
# 3:
class Foo(Bar):
@classmethod
def foo(cls, bar):
super(Bar, cls).foo(bar)
# 4:
class Foo:
class InnerBar(Bar):
def foo(self, bar):
pass
class InnerFoo(InnerBar):
def foo(self, bar):
super(InnerBar, self).foo(bar)
INVALID Code Examples
# 1:
class Foo(Bar):
def foo(self, bar):
super(Foo, self).foo(bar)
Autofix:
---
+++
@@ -1,4 +1,4 @@
class Foo(Bar):
def foo(self, bar):
- super(Foo, self).foo(bar)
+ super().foo(bar)
# 2:
class Foo(Bar):
@classmethod
def foo(cls, bar):
super(Foo, cls).foo(bar)
Autofix:
---
+++
@@ -2,4 +2,4 @@
class Foo(Bar):
@classmethod
def foo(cls, bar):
- super(Foo, cls).foo(bar)
+ super().foo(bar)
# 3:
class Foo:
class InnerFoo(Bar):
def foo(self, bar):
super(Foo.InnerFoo, self).foo(bar)
Autofix:
---
+++
@@ -2,4 +2,4 @@
class Foo:
class InnerFoo(Bar):
def foo(self, bar):
- super(Foo.InnerFoo, self).foo(bar)
+ super().foo(bar)
# 4:
class Foo:
class InnerFoo(Bar):
class InnerInnerFoo(Bar):
def foo(self, bar):
super(Foo.InnerFoo.InnerInnerFoo, self).foo(bar)
Autofix:
---
+++
@@ -3,4 +3,4 @@
class InnerFoo(Bar):
class InnerInnerFoo(Bar):
def foo(self, bar):
- super(Foo.InnerFoo.InnerInnerFoo, self).foo(bar)
+ super().foo(bar)