Advanced Enumerations (compatible with Python's stdlib Enum), NamedTuples, and NamedConstants
76
Build a tiny alert routing helper that relies on typed enumerations for severity and delivery channels.
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. @testformat_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@generates
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]:
...Provides typed enumeration utilities for integer, string, auto-numbered, ordered, and uniqueness-constrained enums.
Install with Tessl CLI
npx tessl i tessl/pypi-aenumevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10