CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-aenum

tessl install tessl/pypi-aenum@3.1.0

Advanced 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%

task.mdevals/scenario-4/

Immutable Payment Status Codes

Create an immutable set of payment status codes and helper utilities for looking them up by numeric value.

Capabilities

Immutable status definitions

  • Exposes four status constants with numeric codes: PENDING = 102, AUTHORIZED = 200, DECLINED = 402, REFUNDED = 209. Each status object exposes name and value properties matching these pairs. @test

Lookup by code

  • Calling status_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. @test

Rebinding protection

  • Attempting to reassign or delete any status (e.g., setting PaymentStatus.PENDING = 0 or del PaymentStatus.DECLINED) raises AttributeError, leaving the original constants unchanged. @test

Listing statuses

  • list_status_codes() returns a list of (name, value) tuples in definition order: [("PENDING", 102), ("AUTHORIZED", 200), ("DECLINED", 402), ("REFUNDED", 209)]. @test

Implementation

@generates

API

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."""

Dependencies { .dependencies }

aenum { .dependency }

Provides immutable constant groups with lookup and iteration support.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/aenum@3.1.x
tile.json