Skip to main content

Abstract class attributes

Project description

abcattrs

CI Build Status
PyPI Package Python versions

Abstract class attributes for ABCs.

Examples

import abc
from abcattrs import abstractattrs, Abstract


@abstractattrs
class A(abc.ABC):
    foo: Abstract[int]


# Abstract subclasses can add more required attributes.
class B(A, abc.ABC):
    bar: Abstract[str]


class C(B):
    # C must assign values to both of these attributes to not raise an error.
    foo = 1
    bar = "str"


# This raises an error.
class MissingBar(B):
    foo = 1


# This raises an error.
class MissingFoo(B):
    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.6.1.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abcattrs-0.6.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file abcattrs-0.6.1.tar.gz.

File metadata

  • Download URL: abcattrs-0.6.1.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for abcattrs-0.6.1.tar.gz
Algorithm Hash digest
SHA256 b72e096890a704bce06ac16c6b7d49c25b30dff27a601d0fdd5d9984b78ec1a1
MD5 2d60a2dd6abcad0af7331863081e5a23
BLAKE2b-256 6d97bfaf421cc15ea18f07dade4088a1a2c43f318bfdee62649cf5001bc60d8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for abcattrs-0.6.1.tar.gz:

Publisher: release.yaml on antonagestam/abcattrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file abcattrs-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: abcattrs-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for abcattrs-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 595d19e9a5e622f2bfb05e8b139eec8d4068b439ed1f6c332620b1dba8741fe8
MD5 1a08990a817cebbf461dc2250ab52f7a
BLAKE2b-256 7696ba2d0ed033a71d1bb7dbf7082c43e2254d1edf03b346787b99f0d051d7bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for abcattrs-0.6.1-py3-none-any.whl:

Publisher: release.yaml on antonagestam/abcattrs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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