Registry / serialization / aenum

aenum

JSON →
library3.1.17pypypi✓ verified 35d ago

aenum is a Python library providing advanced enumerations that are compatible with Python's standard library Enum, along with metaclass-based NamedTuple and NamedConstant implementations. It offers extended features over the built-in `enum` module, such as support for unique values, multiple values, auto-numbering, and control over aliasing. The current version is 3.1.17 and it maintains an active release cadence.

serialization
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from aenum import Enum
from aenum import IntEnum
from aenum import Flag
from aenum import NamedTuple
from aenum import NamedConstant

Use `from aenum import Enum` to access aenum's extended features. Importing from the standard library `enum` module provides a different implementation without aenum's enhancements.

from aenum import Enum

Demonstrates defining a basic Enum with auto-numbering and a simple NamedTuple.

from aenum import Enum, auto class Color(Enum): RED = auto() GREEN = auto() BLUE = auto() print(Color.RED) # Output: <Color.RED: 1> print(Color.GREEN.value) # Output: 2 class MyNamedTuple(NamedTuple): field_a: int field_b: str item = MyNamedTuple(1, 'hello') print(item.field_a) # Output: 1
Debug
Known footguns
breakingVersion 3.1 introduced breaking changes, including the removal of `AutoNumber` and `AutoValue`. Custom Enum settings relying on these features will need to be updated.
gotchaWhen migrating from Python 2 to Python 3, code using `aenum` (or `enum34`) might require special handling for `__order__` in Python 2 to preserve member order, a detail that differs in Python 3.
gotchaBy default, Enum members evaluate to `True` in a boolean context, even if their assigned value is `0`. This differs from standard Python integers where `0` is `False`. If this behavior is undesired, the `__bool__` (Python 3) or `__nonzero__` (Python 2) method must be overridden within the Enum.
gotchaPython 3.11 introduced changes to `enum` mixin class behavior, particularly affecting how `__init__` and `__new__` interact with mixed-in data types, which could lead to unexpected value types for enum members. While some of these changes were later reverted, they represent a potential area of inconsistency when mixing types in Enums with `aenum` on newer Python versions.
gotchaA `NameError: name 'NamedTuple' is not defined` occurs when `NamedTuple` is referenced without being imported from the `typing` module. This is a common Python coding error, not specific to the `aenum` library.
gotchaThe `NamedTuple` class is not a built-in type and must be explicitly imported from the `typing` module (e.g., `from typing import NamedTuple`) before it can be used to define custom named tuple classes.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources