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.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for abcattrs-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ff7340d4326646797b07972640a3d426f4a672a9f61bb9ade86d310ba4208098
MD5 cfe919fe36de2386d1bc3317658e1086
BLAKE2b-256 7e2266118dd705be822d62fd0fefd8c7994ffa9385283cf3ba0723e073cec61b

See more details on using hashes here.

Provenance

The following attestation bundles were made for abcattrs-0.6.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: abcattrs-0.6.0-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.12.9

File hashes

Hashes for abcattrs-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b76ca38d8bf6f9a97620f6d0b19d7a00583ec49b90b8ab1b217a94f994bd85f
MD5 95d04eb218c7e53a8cbd00ec9410b9e7
BLAKE2b-256 cd8a105fce62b969ac1045f2941ad0eb73ec0befb64646effda1b043922f4af0

See more details on using hashes here.

Provenance

The following attestation bundles were made for abcattrs-0.6.0-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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page