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-2/

Alert Routing with Typed Enums

Build a tiny alert routing helper that relies on typed enumerations for severity and delivery channels.

Capabilities

Severity levels

  • Defines four severity levels (LOW, MEDIUM, HIGH, CRITICAL) declared from least to most urgent; integer codes are auto-assigned starting at 1 in declaration order so value comparisons follow the urgency order. @test
  • Converting a severity to an int yields its code, and constructing from the matching int returns the correct level. @test

Channel labels

  • Defines three delivery channels (EMAIL, SMS, PAGER) backed by lowercase string values; converting to a string returns that lowercase value, and duplicate string values are rejected. @test

Routing helpers

  • highest_severity(values) accepts a mix of severities, ints, or member names (case-insensitive) and returns the most urgent severity level using the enumeration ordering, raising ValueError on unknown inputs. @test
  • format_dispatch(severity, channel) returns a mapping { "severity": <int code>, "channel": <string value> } for given inputs, validating types and raising ValueError on invalid severity/channel inputs. @test

Implementation

@generates

API

from typing import Iterable, Mapping, Any

class Severity:
    LOW: "Severity"
    MEDIUM: "Severity"
    HIGH: "Severity"
    CRITICAL: "Severity"

class Channel:
    EMAIL: "Channel"
    SMS: "Channel"
    PAGER: "Channel"

def highest_severity(values: Iterable[Any]) -> Severity:
    ...

def format_dispatch(severity: Severity | int | str, channel: Channel | str) -> Mapping[str, Any]:
    ...

Dependencies { .dependencies }

aenum { .dependency }

Provides typed enumeration utilities for integer, string, auto-numbered, ordered, and uniqueness-constrained enums.

Version

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