pylint-errors

E0101 (return-in-init)

:x: Problematic code:

class Foo:
    def __init__(self, value):
        return value

:heavy_check_mark: Correct code:

class Foo:
    def __init__(self, value):
        self.value = value


foo = Foo([1, 2, 3])
print(foo.value)

Rationale:

Explicit return in __init__ Used when the special class method __init__ has an explicit return value. __init__ magic method is a basically constructor of an instance, so it should constuct it but not return anything. The rest can be achieved through object attributes like method, property, etc.