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

Bitmask Feature Controls

A feature and permission module built around bitmask-based enumerations that combine, test, and round-trip flags without manual bit assignment.

Capabilities

Feature flag composition

Presets are built from single-bit members: DEFAULT = SEARCH | REPORTS, ANALYST = SEARCH | REPORTS | EXPORT, and ADMINISTRATOR = SEARCH | REPORTS | EXPORT | ADMIN.

  • Base feature members (SEARCH, REPORTS, EXPORT, ADMIN) take distinct single-bit values in declaration order so that ADMINISTRATOR equals the bitwise combination of all four and preserves readable member names when printed. @test

Feature enablement helpers

  • Combining DEFAULT with an extra EXPORT flag through enable_features yields a value where has_feature reports true for SEARCH, REPORTS, and EXPORT, and false for ADMIN. @test

Integer permissions interchange

  • Passing 5 to permissions_from_int produces a value that represents READ and EXECUTE but not WRITE, and converting it back with permissions_to_int returns 5. @test

Implementation

@generates

API

from typing import Iterable

class FeatureFlag:
    SEARCH: "FeatureFlag"
    REPORTS: "FeatureFlag"
    EXPORT: "FeatureFlag"
    ADMIN: "FeatureFlag"
    DEFAULT: "FeatureFlag"
    ANALYST: "FeatureFlag"
    ADMINISTRATOR: "FeatureFlag"

class AccessLevel:
    READ: "AccessLevel"
    WRITE: "AccessLevel"
    EXECUTE: "AccessLevel"
    FULL: "AccessLevel"

def enable_features(plan: FeatureFlag, extras: Iterable[FeatureFlag] | None = None) -> FeatureFlag:
    """Return a combined set of features from a base plan plus optional extras."""

def has_feature(active: FeatureFlag, feature: FeatureFlag) -> bool:
    """Check whether the active feature set includes the requested flag."""

def permissions_from_int(raw: int) -> AccessLevel:
    """Convert an integer mask into an access-level value."""

def permissions_to_int(level: AccessLevel) -> int:
    """Convert an access-level value back to its integer mask."""

Dependencies { .dependencies }

aenum { .dependency }

Advanced enumeration utilities with flag-style bitmask support.

Version

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