Registry / serialization / aenum
library3.1.17pypypi✓ verified 25d 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.

pip install aenum
INSTALL
IMPORT
SIG · AENUM
A
aenum
serializationpythonv3.1.17
Install
1.8s avg
Import
61ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.1.17 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.062s · 19.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.060s · 20MB
18MB installed
● package 18MB
Code
Verified usage

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

Enum
from aenum import Enum
IntEnum
from aenum import IntEnum
Flag
from aenum import Flag
NamedTuple
from aenum import NamedTuple
NamedConstant
from aenum import NamedConstant
Enum
from aenum import Enum
from enum import Enum
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.

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 issues
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.
fix
Migrate away from `AutoNumber` and `AutoValue`. Consider using `aenum.auto()` or manual value assignment.
affects: >=3.1.0
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.
fix
Ensure `__order__` is correctly defined for Enums in Python 2 if explicit ordering is required, or rely on natural definition order in Python 3. Consider modernizing to Python 3 exclusively where possible.
affects: Python 2.x to Python 3.x
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.
fix
Explicitly check `member.value` for its numeric truthiness, or override `__bool__` if the Enum member itself should reflect the truthiness of its value.
affects: All versions
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.
fix
Carefully test Enums that use mixed-in types when upgrading to Python 3.11 or later. Consult the `enum` module's documentation for Python 3.11+ regarding `__new__` and `__init__` behavior with mixins if encountering issues.
affects: Python 3.11+
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.
fix
Ensure `NamedTuple` is imported from the `typing` module (e.g., `from typing import NamedTuple`) before use.
affects: All Python 3 versions where `NamedTuple` is used.
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.
fix
Add `from typing import NamedTuple` at the top of the script or module where `NamedTuple` is being used.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'aenum'
The 'aenum' module is not installed in the Python environment.
fix
Install the 'aenum' module using pip: 'pip install aenum'.
TypeError: issubclass() arg 1 must be a class
Incorrect usage of the 'Enum' class constructor with positional arguments instead of keyword arguments.
fix
Use the 'Enum' constructor with keyword arguments: 'Enum('EnumName', {'member1': value1, 'member2': value2})'.
ValueError: 8 is not a valid DataType
Attempting to retrieve an Enum member by value when the Enum members have list or tuple values.
fix
Use a custom method to search for the Enum member by iterating over the Enum members and checking if the value is in the member's value list.
ModuleNotFoundError: No module named 'aenum._common'
This error typically occurs due to an incomplete or corrupted `aenum` installation, often seen with specific versions (e.g., 3.1.13, 3.1.14) or when using PyPy, where internal modules like `_common` are not found.
fix
Upgrade `aenum` to the latest version to resolve packaging issues or compatibility fixes: `pip install --upgrade aenum`
AttributeError: module 'aenum._common' has no attribute 'NoneType'
This error indicates a compatibility issue with certain Python implementations (like PyPy) and specific `aenum` versions, where a required internal type `NoneType` is not correctly exposed or handled by the `aenum._common` module.
fix
Upgrade `aenum` to the latest stable version, as this specific issue was often resolved in subsequent releases: `pip install --upgrade aenum`
Upgrade
Version history
3.1.17latest on PyPI · released Mar 20, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
57 hits · last 30 days
node
48
OpenAI (training)
1
Resources
aenum — pip install aenum · libregistry