Pattern: super()
not using child class name as first argument
Issue: -
The first argument to super()
should be the name of the current child class calling super()
. If a valid child class name is not provided Python will raise a TypeError
at runtime.
Example of incorrect code:
class Felinae(object):
def __init__(self, name):
self.name = name
class Puma(Felinae):
def __init__(self, name):
# bad first argument to super()
super(self, Puma).__init__(name)
Example of correct code:
class Felinae(object):
def __init__(self, name):
self.name = name
class Puma(Felinae):
def __init__(self, name):
super(Puma, self).__init__(name)