Abstract class attributes
Project description
abcattrs
Abstract class attributes for ABCs.
import abc
from abcattrs import abstractattrs, Abstract
@abstractattrs
class A(abc.ABC):
foo: Abstract[int]
# Abstract subclasses can add more required attributes
@abstractattrs
class B(A, abc.ABC):
bar: Abstract[str]
class C(B):
# C must define both of these attributes to not raise an error
foo = 1
bar = "str"
The Abstract
qualifier can be combined with other PEP 593 annotations.
from typing import Annotated
import abc
from abcattrs import abstractattrs, Abstract
@abstractattrs
class A(abc.ABC):
# Combine with other annotations
bar: Annotated[str, Abstract, "other info"]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
abcattrs-0.4.0.tar.gz
(5.2 kB
view details)
Built Distribution
File details
Details for the file abcattrs-0.4.0.tar.gz
.
File metadata
- Download URL: abcattrs-0.4.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98e9932fbd064b5e5233819e2a5a791e5befd06f2bc87f9fa19dc431fbef18da |
|
MD5 | b09a82bf2ae03dfb30835526f144c91c |
|
BLAKE2b-256 | 7bb30d24923cd7e81a1cecc56d7a222d2c3f485f11ef24c17bb7efccb76214eb |
File details
Details for the file abcattrs-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: abcattrs-0.4.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d29dce5ed845ae329bff6204bf9bd5d97f7dfcc48548802b883d7d7fa8edf606 |
|
MD5 | 7e0a3d2f2dadba98ef277bb9e59d6359 |
|
BLAKE2b-256 | e12c66d3cb589b6c61ba2f5fa61c84481975bbfaed5a18fe4c743579154b33a6 |