CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-aenum

Advanced Enumerations (compatible with Python's stdlib Enum), NamedTuples, and NamedConstants

76

1.20x
Overview
Eval results
Files

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.

Install with Tessl CLI

npx tessl i tessl/pypi-aenum

tile.json