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

Configuration Registry System

Build a simple configuration registry that automatically tracks the names of configuration objects when they are created.

Requirements

Create a configuration registry system with the following capabilities:

Configuration Class

Implement a Config class that:

  • Automatically captures and stores the variable name it's assigned to when instantiated
  • Stores a dictionary of configuration values passed during initialization
  • Provides a name property that returns the captured variable name
  • Provides a values property that returns the configuration dictionary

Registry Manager

Implement a ConfigRegistry class that:

  • Maintains a collection of all registered Config instances
  • Provides a register() method that accepts a Config instance and stores it using its captured name as the key
  • Provides a get(name) method that retrieves a registered config by its name
  • Provides a list_configs() method that returns a list of all registered config names

Test Cases

  • Creating a config object database_config = Config({"host": "localhost", "port": 5432}) should automatically capture "database_config" as its name @test
  • The registry should be able to store and retrieve configs by their captured names @test
  • Multiple config objects should each capture their own unique variable names @test

Implementation

@generates

API

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."""
        pass

Dependencies { .dependencies }

varname { .dependency }

Provides variable name introspection capabilities.