Skip to content

B024 should be satisfied by class attribute declarations like attr: ClassVar[T] #293

@Zac-HD

Description

@Zac-HD

In addition to traditional abstract methods, ABC could just be there to declare a class variable that should be set for concrete classes in a less verbose way than using annotations and properties:

class Abstract(ABC):
    attr: ClassVar[str]

This is checked by mypy and will also raise an AttributeError if trying to access attr on a concrete class that doesn't set it. See https://peps.python.org/pep-0526/

Originally posted by @alk-gpajot in #278 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions