CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-varname

Dark magics about variable names in python

Overall
score

90%

Overview
Eval results
Files

task.mdevals/scenario-10/

Configuration Value Tracker

Build a system for creating self-documenting configuration values that automatically track both their assigned variable name and their value.

Problem Description

You need to implement a configuration entry system that captures configuration values along with their variable names. When a configuration entry is created and assigned to a variable, it should automatically remember the variable name it was assigned to, making it easy to trace and debug configuration settings.

Requirements

Configuration Entry Creation

Create a class ConfigEntry that wraps configuration values while automatically capturing the variable name they're assigned to. Each entry should store both the configuration value and the name it was assigned to.

Value and Name Access

Configuration entries should provide:

  • Access to the underlying configuration value via a value attribute
  • Access to the captured variable name via a name attribute
  • A string representation showing both the name and value

Multiple Entry Support

The system should work correctly when creating multiple configuration entries, with each one capturing its own unique variable name.

Test Cases

  • Creating a configuration entry automatically captures the variable name it's assigned to @test
  • Configuration entries correctly store their assigned values @test
  • String representation shows both name and value in readable format @test
  • Multiple configuration entries each capture their own unique variable names @test

Implementation

@generates

API

class ConfigEntry:
    """
    A configuration entry that bundles a value with its variable name.

    Attributes:
        name: The variable name this entry was assigned to
        value: The configuration value stored in this entry
    """
    def __init__(self, value):
        """
        Initialize a configuration entry with a value.
        The variable name is automatically captured.

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

    def __str__(self):
        """
        Return a string representation showing the name and value.

        Returns:
            A string representation of the entry
        """
        pass

Dependencies { .dependencies }

varname { .dependency }

Provides metaprogramming capabilities for variable name introspection.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-varname

tile.json