attribute-defined-outside-init / W0201ΒΆ

Message emitted:

Attribute %r defined outside __init__

Description:

Used when an instance attribute is defined outside the __init__ method.

Problematic code:

class Student:
    def register(self):
        self.is_registered = True  # [attribute-defined-outside-init]

Correct code:

class Student:
    def __init__(self):
        self.is_registered = False

    def register(self):
        self.is_registered = True

Created by the classes checker.