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

Telemetry Reading Tuple

Design a tuple-backed data structure for telemetry readings with strict field control, alias-friendly accessors, and validation suitable for small device payloads.

Capabilities

Enforced length and order

  • Constructing with four required values (device_id, state, temp_c, humidity_percent) yields an object of length 4 whose iteration/unpacking returns those values in that order. @test
  • Supplying fewer than four values raises a ValueError describing the missing data. @test

Alias accessors

  • Accessing id returns the same value as device_id, and status returns the same value as state; these aliases do not change the tuple length or order. @test

Optional diagnostics

  • Passing extra trailing diagnostic strings preserves the first four positions unchanged and exposes all extras through a diagnostics attribute as a tuple in the order provided. @test

Validation hook

  • Construction fails with a ValueError when state is not "ok" or "alert", or when humidity_percent falls outside 0–100, before a reading is returned. @test

Implementation

@generates

API

class TelemetryReading(tuple):
    device_id: str
    id: str  # alias for device_id
    state: str
    status: str  # alias for state
    temp_c: float
    humidity_percent: float
    diagnostics: tuple[str, ...]

    def __new__(
        cls,
        device_id: str,
        state: str,
        temp_c: float,
        humidity_percent: float,
        *diagnostics: str,
    ) -> "TelemetryReading": ...

Dependencies { .dependencies }

aenum { .dependency }

Provides enhanced enum and tuple helpers used to enforce tuple sizing, aliases, ordering, and value review logic.

Version

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