Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Zac-HD opened this issue Sep 29, 2022 · 0 comments
Closed

Comments

@Zac-HD
Copy link
Member

Zac-HD commented Sep 29, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant