Skip to main content

enum-adt

Enum Algebraic Data Types (ADTs) for Python.

Installation

Run the following command to install the Python package on Python 3.8 or later:

pip install enum-adt

Or you can simply copy the enum_adt.py file anywhere in your project.

Usage

from enum_adt import ADT

class MyEnum(ADT):
    class Foo: ...

    class Bar:
        name: str

foo = MyEnum.Foo()
bar = MyEnum.Bar("bar")
assert isinstance(foo, MyEnum)
assert isinstance(bar, MyEnum)

Alternatively, you can use metaclass:

from enum_adt import ADTMeta

class MyEnum(metaclass=ADTMeta):
    class Foo: ...

    class Bar:
        name: str

Each internal class will be created as a dataclass with the same attributes. You can customize the dataclass by passing arguments to the class:

All enum variants get the same arguments.

from enum_adt import ADT

class MyEnum(ADT, frozen=True, kw_only=True):
    class Foo: ...

    class Bar:
        name: str

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Metadata

Release files for enum-adt 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enum-adt 0.0.2
File Size Uploaded Provenance Actions
enum_adt-0.0.2.tar.gz 2.9 kB Without provenance Details for enum_adt-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for enum-adt 0.0.2
File Interpreter ABI Platform Actions
enum_adt-0.0.2-py3-none-any.whl Python 3 none any Details for enum_adt-0.0.2-py3-none-any.whl

Total release size: 6.1 kB

Release files / enum_adt-0.0.2.tar.gz

Download URL enum_adt-0.0.2.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
08b8ee69ed02772783d665e8863aa063783f34a4b4745d5e77a76cd282060c15
BLAKE2b-256 checksum
How to use checksums
66605ec0e1dcb108b0b876bd2f867653fbb3d37a317f1162ead7d94cbed922c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / enum_adt-0.0.2-py3-none-any.whl

Download URL enum_adt-0.0.2-py3-none-any.whl
Size 3.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ac641f570286346c051b1d4177f79b27fd03cbb4839edb9e951915ca0a5db64
BLAKE2b-256 checksum
How to use checksums
3ced359af9b0853e82bd5891f79e38d440226b496efb6cf37ed9e6342cb34fca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Security for enum-adt 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page