or run

tessl search
Log in

Version

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

tessl/pypi-varname

tessl install tessl/pypi-varname@0.15.0

Dark magics about variable names in python

Agent Success

Agent success rate when using this tile

90%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.41x

Baseline

Agent success rate without this tile

64%

task.mdevals/scenario-7/

Async Task Result Manager

Build a task manager that tracks and stores async operation results using the variable names they're assigned to as identifiers.

Requirements

Create a system that:

  1. Captures the variable name when an async operation completes and stores the result with that name as its identifier
  2. Provides a way to retrieve stored results by their identifier
  3. Supports async operations that return values which should be automatically registered
  4. Provides a function to list all registered task results with their identifiers

The system should work seamlessly with Python's async/await syntax, automatically capturing variable names from async function calls.

Test Cases

  • When an async function result is assigned to a variable, the result should be stored with the variable name as the identifier @test
  • When multiple async function results are assigned to different variables, each should be stored with its respective variable name @test
  • Retrieving a stored result by identifier should return the correct value @test
  • Listing all results should return all identifiers and their values @test

Implementation

@generates

API

class TaskResult:
    """Represents the result of an async task with automatic variable name capture."""

    def __init__(self, value):
        """
        Initialize a task result that captures its variable name.

        Args:
            value: The value to store
        """
        pass

    @property
    def identifier(self):
        """Get the identifier (variable name) for this result."""
        pass

    @property
    def value(self):
        """Get the stored value."""
        pass


async def create_task_result(value):
    """
    Create a task result asynchronously.

    Args:
        value: The value to wrap in a TaskResult

    Returns:
        TaskResult: A result object with automatic variable name capture
    """
    pass


class TaskRegistry:
    """Registry for storing and retrieving task results by identifier."""

    def __init__(self):
        """Initialize an empty task registry."""
        pass

    def register(self, task_result):
        """
        Register a task result in the registry.

        Args:
            task_result: A TaskResult instance to register
        """
        pass

    def get(self, identifier):
        """
        Retrieve a task result by its identifier.

        Args:
            identifier: The identifier (variable name) to look up

        Returns:
            The value stored under that identifier, or None if not found
        """
        pass

    def list_all(self):
        """
        List all registered results.

        Returns:
            dict: A dictionary mapping identifiers to their values
        """
        pass

Dependencies { .dependencies }

varname { .dependency }

Provides variable name introspection support for capturing variable names at runtime.