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 simple configuration registry that automatically tracks the names of configuration objects when they are created.
Create a configuration registry system with the following capabilities:
Implement a Config class that:
name property that returns the captured variable namevalues property that returns the configuration dictionaryImplement a ConfigRegistry class that:
Config instancesregister() method that accepts a Config instance and stores it using its captured name as the keyget(name) method that retrieves a registered config by its namelist_configs() method that returns a list of all registered config namesdatabase_config = Config({"host": "localhost", "port": 5432}) should automatically capture "database_config" as its name @test@generates
class Config:
"""A configuration object that captures its variable name."""
def __init__(self, values: dict):
"""Initialize with configuration values."""
pass
@property
def name(self) -> str:
"""Return the captured variable name."""
pass
@property
def values(self) -> dict:
"""Return the configuration values."""
pass
class ConfigRegistry:
"""Registry for managing named configuration objects."""
def __init__(self):
"""Initialize empty registry."""
pass
def register(self, config: Config) -> None:
"""Register a config object using its captured name."""
pass
def get(self, name: str) -> Config:
"""Retrieve a registered config by name."""
pass
def list_configs(self) -> list[str]:
"""Return list of all registered config names."""
passProvides variable name introspection capabilities.