Skip to main content

Abstract class attributes

Project description

abcattrs

CI Build Status
PyPI Package Python versions

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)

Uploaded Source

Built Distribution

abcattrs-0.4.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

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

Hashes for abcattrs-0.4.0.tar.gz
Algorithm Hash digest
SHA256 98e9932fbd064b5e5233819e2a5a791e5befd06f2bc87f9fa19dc431fbef18da
MD5 b09a82bf2ae03dfb30835526f144c91c
BLAKE2b-256 7bb30d24923cd7e81a1cecc56d7a222d2c3f485f11ef24c17bb7efccb76214eb

See more details on using hashes here.

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

Hashes for abcattrs-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d29dce5ed845ae329bff6204bf9bd5d97f7dfcc48548802b883d7d7fa8edf606
MD5 7e0a3d2f2dadba98ef277bb9e59d6359
BLAKE2b-256 e12c66d3cb589b6c61ba2f5fa61c84481975bbfaed5a18fe4c743579154b33a6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page