What problem does it solve?
Evolving Pydantic configuration schemas while maintaining backward compatibility, handling environment variables, and providing automated migration paths is challenging. This skill provides patterns to manage config changes gracefully, preventing breaking changes and simplifying updates.
Core Features & Use Cases
- Backward-Compatible Schema Evolution: Add new config sections and fields without breaking existing configurations.
- Type Discrimination: Implement discriminated unions for flexible configuration of different types (e.g., CLI vs. HTTP adapters).
- Environment Variable Substitution: Securely inject secrets and dynamic values from environment variables into your config.
- Automated Migration Scripts: Create robust Python scripts to automatically update old config files to new formats, including backups.
- Use Case: Migrate an existing
config.yaml from a legacy cli_tools section to a new adapters section, automatically adding type: cli to each entry, without requiring manual edits from users.
Quick Start
To migrate your config.yaml from the deprecated cli_tools format to the new adapters format, run the provided migration script:
python scripts/migrate_config.py config.yaml