Enum Tools is a Python library that expands upon Python's standard `enum` module. It provides utilities such as a Sphinx extension (`autoenum`) for improved Enum documentation, decorators (`document_enum`) to automatically add docstrings to Enum members from source code comments, and a collection of custom Enum classes (`custom_enums`) with enhanced functionality like `StrEnum`, `AutoNumberEnum`, and `OrderedEnum`. The library is currently at version 0.13.0 and maintains an active release schedule.
pip install enum-toolsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the `document_enum` decorator to add docstrings from line comments and the `StrEnum` from `custom_enums` which allows enum members to behave like strings.
Use a single, consistent docstring format (`# doc: Comment`) for each enum member.
Avoid changing enum member values in production code once they are established. If values must change, consider migrating old data or implementing compatibility layers.
Install with `pip install enum-tools[sphinx]` if you plan to use the Sphinx extension.
pip install enum-tools
from enum_tools.custom_enums import StrEnum
pip install enum-tools[sphinx]
Ensure each enum member has its docstring defined using only one consistent format, for example, a single '# doc: Your docstring' comment per member.