tessl install tessl/pypi-varname@0.15.0Dark 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%
Build a task manager that tracks and stores async operation results using the variable names they're assigned to as identifiers.
Create a system that:
The system should work seamlessly with Python's async/await syntax, automatically capturing variable names from async function calls.
@generates
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
"""
passProvides variable name introspection support for capturing variable names at runtime.