Skip to main content

Abstract class attributes

Project description

abcattrs

CI Build Status

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.3.0.tar.gz (4.9 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.3.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: abcattrs-0.3.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for abcattrs-0.3.0.tar.gz
Algorithm Hash digest
SHA256 932dcd449cd8cfb0e31c3f67e91f8f4881b89350792084551fb2ce639cb57e39
MD5 3a58d3d36e1485e6e92c5ad2d428100c
BLAKE2b-256 0a5fede7cef2bbfef27a26b0b06e47b2a373bba1a8f376f7bcc3321857239a14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: abcattrs-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for abcattrs-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7718c3e8cb732329d2ecc70c03d36b127277f71d3a9faa29ea1488d3d9d6224
MD5 61c8655194184b090a11d0465dd889e2
BLAKE2b-256 1521e19be0cb96190235ae2929e45805c2cbe27147d321b05a5cd7c247e6c0de

See more details on using hashes here.

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