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%
Create an immutable set of payment status codes and helper utilities for looking them up by numeric value.
PENDING = 102, AUTHORIZED = 200, DECLINED = 402, REFUNDED = 209. Each status object exposes name and value properties matching these pairs. @teststatus_from_code(200) returns the status object for AUTHORIZED, and status_from_code(402) returns the one for DECLINED. Unknown codes raise ValueError. Repeated lookups for the same code return the same status object instance. @testPaymentStatus.PENDING = 0 or del PaymentStatus.DECLINED) raises AttributeError, leaving the original constants unchanged. @testlist_status_codes() returns a list of (name, value) tuples in definition order: [("PENDING", 102), ("AUTHORIZED", 200), ("DECLINED", 402), ("REFUNDED", 209)]. @test@generates
class PaymentStatus:
PENDING: int
AUTHORIZED: int
DECLINED: int
REFUNDED: int
def status_from_code(code: int) -> PaymentStatus:
"""Return the status constant for a numeric code or raise ValueError."""
def list_status_codes() -> list[tuple[str, int]]:
"""Return (name, value) pairs for all statuses in definition order."""Provides immutable constant groups with lookup and iteration support.