tessl install tessl/pypi-aenum@3.1.0Advanced Enumerations (compatible with Python's stdlib Enum), NamedTuples, and NamedConstants
Agent Success
Agent success rate when using this tile
76%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.21x
Baseline
Agent success rate without this tile
63%
Build a small utility that generates enumeration types for access levels at runtime and provides helpers for resolving and listing those levels.
(name, value) pairs, create an enumeration type whose members and order mirror the provided pairs; reject duplicate names or values. @testresolve_level returns the matching member when given either a member name string (case-sensitive) or its numeric value; it raises ValueError for invalid queries. @testlist_levels returns a list of (name, value) tuples reflecting the enumeration's iteration order. @test@generates
from typing import Iterable, Tuple, Union, Any
def create_level_enum(levels: Iterable[Tuple[str, int]]):
"""Return an enumeration type whose members and order match the provided pairs; reject duplicate names or values."""
def resolve_level(level_enum: Any, query: Union[str, int]):
"""Return the enumeration member matching a name or value; raise ValueError if the query is invalid."""
def list_levels(level_enum: Any):
"""Return a list of (name, value) pairs in the enumeration's iteration order."""Provides advanced enumeration support.