{"id":460,"library":"aenum","title":"aenum - Advanced Enumerations","description":"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.","status":"active","version":"3.1.17","language":"python","source_language":"en","source_url":"https://github.com/ethanfurman/aenum","tags":["enum","enumeration","namedtuple","namedconstant","constants","stdlib-enhancement"],"install":[{"cmd":"pip install aenum","lang":"bash","label":"Install aenum"}],"dependencies":[],"imports":[{"symbol":"Enum","correct":"from aenum import Enum"},{"symbol":"IntEnum","correct":"from aenum import IntEnum"},{"symbol":"Flag","correct":"from aenum import Flag"},{"symbol":"NamedTuple","correct":"from aenum import NamedTuple"},{"symbol":"NamedConstant","correct":"from aenum import NamedConstant"},{"note":"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.","wrong":"from enum import Enum","symbol":"Enum","correct":"from aenum import Enum"}],"quickstart":{"code":"from aenum import Enum, auto\n\nclass Color(Enum):\n    RED = auto()\n    GREEN = auto()\n    BLUE = auto()\n\nprint(Color.RED) # Output: <Color.RED: 1>\nprint(Color.GREEN.value) # Output: 2\n\nclass MyNamedTuple(NamedTuple):\n    field_a: int\n    field_b: str\n\nitem = MyNamedTuple(1, 'hello')\nprint(item.field_a) # Output: 1","lang":"python","description":"Demonstrates defining a basic Enum with auto-numbering and a simple NamedTuple."},"warnings":[{"fix":"Migrate away from `AutoNumber` and `AutoValue`. Consider using `aenum.auto()` or manual value assignment.","message":"Version 3.1 introduced breaking changes, including the removal of `AutoNumber` and `AutoValue`. Custom Enum settings relying on these features will need to be updated.","severity":"breaking","affected_versions":">=3.1.0"},{"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.","message":"When 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.","severity":"gotcha","affected_versions":"Python 2.x to Python 3.x"},{"fix":"Explicitly check `member.value` for its numeric truthiness, or override `__bool__` if the Enum member itself should reflect the truthiness of its value.","message":"By 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.","severity":"gotcha","affected_versions":"All 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.","message":"Python 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.","severity":"gotcha","affected_versions":"Python 3.11+"},{"fix":"Ensure `NamedTuple` is imported from the `typing` module (e.g., `from typing import NamedTuple`) before use.","message":"A `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.","severity":"gotcha","affected_versions":"All Python 3 versions where `NamedTuple` is used."},{"fix":"Add `from typing import NamedTuple` at the top of the script or module where `NamedTuple` is being used.","message":"The `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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T13:57:33.304Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Install the 'aenum' module using pip: 'pip install aenum'.","cause":"The 'aenum' module is not installed in the Python environment.","error":"ModuleNotFoundError: No module named 'aenum'"},{"fix":"Use the 'Enum' constructor with keyword arguments: 'Enum('EnumName', {'member1': value1, 'member2': value2})'.","cause":"Incorrect usage of the 'Enum' class constructor with positional arguments instead of keyword arguments.","error":"TypeError: issubclass() arg 1 must be a class"},{"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.","cause":"Attempting to retrieve an Enum member by value when the Enum members have list or tuple values.","error":"ValueError: 8 is not a valid DataType"},{"fix":"Upgrade `aenum` to the latest version to resolve packaging issues or compatibility fixes: `pip install --upgrade aenum`","cause":"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.","error":"ModuleNotFoundError: No module named 'aenum._common'"},{"fix":"Upgrade `aenum` to the latest stable version, as this specific issue was often resolved in subsequent releases: `pip install --upgrade aenum`","cause":"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.","error":"AttributeError: module 'aenum._common' has no attribute 'NoneType'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.06,"mem_mb":1.8,"disk_size":"19.3M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.8,"disk_size":"20M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.1,"mem_mb":1.9,"disk_size":"21.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":1.9,"disk_size":"22M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":1.7,"disk_size":"13.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.08,"mem_mb":1.7,"disk_size":"14M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.07,"mem_mb":2,"disk_size":"13.2M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.09,"mem_mb":1.8,"disk_size":"14M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.05,"mem_mb":1.6,"disk_size":"18.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.04,"mem_mb":1.6,"disk_size":"19M"}]},"quickstart_checks":{"last_tested":"2026-04-23","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}