tessl install tessl/pypi-fastcore@1.8.0Python supercharged for fastai development
Agent Success
Agent success rate when using this tile
56%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.37x
Baseline
Agent success rate without this tile
41%
Build a configuration management system that loads settings from dictionaries and provides lifecycle hooks for validation and setup. The system should support inheritance, avoid unnecessary object recreation, and maintain proper type signatures for IDE support.
Create a ConfigManager class that:
Create a ValidatedConfigManager class that:
settings dict and required_keys list in constructor{"host": "localhost", "port": 8080} stores both as attributes @test{"api_key": "secret", "db_host": "localhost"} and required_keys ["api_key", "db_host"] validates successfully @test{"api_key": "secret"} and required_keys ["api_key", "db_host"] raises validation error during initialization @test@generates
class ConfigManager:
"""
Base configuration manager with lifecycle hooks.
Automatically calls _setup() before __init__ and _validate() after __init__.
Maintains proper signature for IDE support despite custom __new__.
"""
def __init__(self, settings: dict):
"""
Initialize configuration manager.
Args:
settings: Dictionary of configuration key-value pairs
"""
pass
def _setup(self):
"""Called before __init__. Override for setup logic."""
pass
def _validate(self):
"""Called after __init__. Override for validation logic."""
pass
def __new__(cls, *args, **kwargs):
"""Custom object creation."""
pass
class ValidatedConfigManager:
"""
Configuration manager with required key validation.
Validates that required keys are present in settings. Maintains
proper signature. Avoids recreating existing instances.
"""
def __init__(self, settings: dict, required_keys: list):
"""
Initialize with required keys for validation.
Args:
settings: Dictionary of configuration key-value pairs
required_keys: List of keys that must be present in settings
"""
pass
def __new__(cls, *args, **kwargs):
"""Custom object creation to avoid recreating existing instances."""
passProvides metaprogramming utilities including metaclasses for enhanced class behavior.