Releases: lzjever/varlord
Releases · lzjever/varlord
Release v0.8.0
Added
-
Security
- Security scan script (
scripts/security-scan.sh) for detecting:- Certificate/key files in git history
- Potential secrets in code
- Dependency vulnerabilities (pip-audit)
- Automatic TLS warnings when connecting to etcd without encryption
- Certificate file existence validation in etcd source
- CI/CD security gates for dependency scanning and secret detection
- Security scan script (
-
Code Quality
- Unified exception hierarchy with base class
VarlordError - Eight specific exception classes with error codes:
ConfigError,ConfigLoadError,SourceLoadErrorValidationError,RequiredFieldError,ModelDefinitionErrorConversionError,ResolverError
- Refactored
Config._flatten_to_nested()method (200 → 34 lines, -83%) - Six new helper methods for better code organization:
_unwrap_optional_type()- Handle Optional[T] types_process_dataclass_instances()- Convert dataclass instances_process_flat_keys()- Process flat configuration keys_collect_nested_keys()- Collect nested configuration_process_nested_keys()- Process nested structures_convert_to_dataclasses()- Convert to dataclass instances
- Unified exception hierarchy with base class
-
Testing Infrastructure
- Test fixtures directory structure (
tests/fixtures/) - Seven test data files (YAML/JSON/TOML/ENV)
- Five new pytest fixtures (datadir, yaml_datadir, json_datadir, toml_datadir, env_datadir)
- Ten new tests for fixtures functionality
- Test data separation from test code
- Test fixtures directory structure (
-
Documentation
- Comprehensive architecture documentation (
docs/architecture/system-design.md)- Six Mermaid diagrams (components, data flow, algorithms)
- Design principles and module structure
- Performance and security considerations
- Two Architecture Decision Records (ADRs):
- [ADR 001] Double underscore separator for nested keys
- [ADR 002] Automatic model injection into sources
- Pull request template with comprehensive checklist
- CLAUDE.md guide for Claude Code integration
- REFACTORING_PROGRESS.md for tracking improvements
.env.exampletemplate for local development
- Comprehensive architecture documentation (
Changed
-
Breaking Change: Exception hierarchy - All custom exceptions now inherit from
VarlordError- Old code catching
Exceptionwill still work - Code catching specific exceptions (e.g.,
ValueError) may need updates - Migration guide: Use
except VarlordErrorto catch all varlord exceptions
- Old code catching
-
etcd source now validates certificate file existence before connecting
- Raises
FileNotFoundErrorif certificate files don't exist - Shows
RuntimeWarningwhen connecting without TLS
- Raises
-
Internal refactoring of
Config._flatten_to_nested()method- No functional changes
- Significantly improved code maintainability
Fixed
- Eliminated three instances of duplicate code for Optional[Dataclass] handling
- Improved error messages with source name and error codes
- Fixed TLS validation in etcd source (certificate file checks)
Security
- No known vulnerabilities in dependencies
- No leaked secrets in git history
- CI/CD automatically scans for security issues
Performance
- Reduced cyclomatic complexity from >15 to ~5 in
_flatten_to_nested() - No performance degradation (all 417/418 tests pass)
Documentation
- Added comprehensive architecture documentation with 6 Mermaid diagrams
- Added two ADRs documenting key design decisions
- Added PR template for better contribution process
- Improved inline documentation with examples
Tests
- Added 10 new tests for fixtures functionality
- Total test count: 418 (407 unit + 11 integration)
- Test pass rate: 99.76% (417/418)
- Separated test data from test code
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependenciesRelease v0.7.3
Changed
- CLI arguments can not use underscores any more - Improve consistancy
- Update docs - Sync with the latest code, variable mapping more clear
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependenciesRelease v0.7.2
- Hotfix, resolve CLI arg string escaping bug.
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependenciesRelease v0.7.1
Added
- Configuration Export Functionality: New methods to export current configuration to various file formats
Config.to_dict()- Get current configuration as dictionaryConfig.dump_json(file_path, ...)- Export configuration to JSON fileConfig.dump_yaml(file_path, ...)- Export configuration to YAML fileConfig.dump_toml(file_path, ...)- Export configuration to TOML fileConfig.dump_env(file_path, ...)- Export configuration to .env file- All export methods handle nested dataclass structures correctly
- Support for custom options (prefix, uppercase, nested separator for .env export)
- Clear error messages for missing optional dependencies (PyYAML, tomli-w)
- Enhanced Diagnostic Table: Improved
--check-variablesoutput- Now filters out non-leaf nodes (intermediate nested config objects)
- Only displays leaf-level configuration variables (e.g.,
ai.completion.modelinstead ofai.completion) - Cleaner, more focused diagnostic output for nested configurations
Changed
format_diagnostic_table()now only shows leaf nodes in variable status table- Export methods use
asdict()for proper nested dataclass conversion
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependenciesRelease v0.7.0
Added
- Env Source Prefix Support: Added
prefixparameter toEnvsource for filtering environment variablessources.Env(prefix="TITAN__")- Only loads environment variables starting with the specified prefix- Case-insensitive prefix matching (e.g.,
titan__matchesTITAN__) - Prefix is automatically removed before key normalization
- Useful for isolating application-specific environment variables in containerized deployments
- Enhanced Nested Dataclass Validation: Improved validation logic for nested dataclass fields
- Parent dataclass fields are now considered "present" if any of their child fields exist
- Fixes false positive
RequiredFieldErrorwhen nested fields are provided via dot notation
- Improved
_flatten_to_nestedMethod: Enhanced nested dataclass instantiation from flattened dictionaries- Now correctly collects all child keys for a parent before recursively processing them
- Properly handles
Optional[Dataclass]types - Filters out
init=Falsefields before passing arguments to dataclass constructors - Fixes
TypeErrorwhen instantiating nested dataclasses with multiple required fields
Fixed
- Fixed
_flatten_to_nestedbug where only partial fields were passed to nested dataclass constructors - Fixed validation logic incorrectly flagging parent dataclass fields as missing when child fields were present
- Fixed handling of
init=Falsefields in nested dataclass instantiation - Fixed
Optional[Dataclass]type handling in nested configuration loading
Changed
Envsource now supports optionalprefixparameter (backward compatible)- Enhanced error messages for nested configuration validation
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependenciesRelease v0.6.0
Added
- File-Based Sources: New YAML, JSON, and TOML sources for loading configuration from files
sources.YAML(file_path, ...)- Load configuration from YAML filessources.JSON(file_path, ...)- Load configuration from JSON filessources.TOML(file_path, ...)- Load configuration from TOML files- All file sources support nested configuration structures (automatically flattened to dot notation)
- All file sources support
required=Falseparameter for graceful handling of missing files - Missing files return empty dict and show "Not Available" status in
--check-variables
- Source ID System: Enhanced source identification for multiple sources of the same type
- Each source now has a unique
idproperty (in addition toname) - Custom source IDs can be specified via
source_idparameter - Automatic ID generation based on source type and key parameters
PriorityPolicynow supports both source names and source IDs- Multiple sources of the same type can be used with different priorities
- Each source now has a unique
- Enhanced Diagnostic Table: Improved
--check-variablesoutput- Added "Status" column showing source load status ("Active", "Not Available", "Failed: ...")
- Better error messages for missing files (shows "Not Available" instead of "Error")
- Source status tracking via
load_statusandload_errorproperties
- Improved Error Messages: Required field errors now include field descriptions from metadata
RequiredFieldErrormessages now show field descriptions when available- More user-friendly error messages with actionable guidance
Changed
- Dependencies: Moved
python-dotenv,pyyaml, andtomlifrom optional to core dependenciesdotenv,yaml, andtomlsources are now always available- Only
etcdremains as an optional dependency
- Etcd Source: Removed
Etcd.from_env()method- All parameters must now be passed explicitly via
__init__ - Users should read environment variables themselves and pass to
Etcd() - This aligns with the principle that the library should not implicitly read environment variables for its own configuration
- All parameters must now be passed explicitly via
- Source Base Class: Enhanced
Sourcebase class with status tracking- Added
_load_statusattribute ("success", "not_found", "failed", "unknown") - Added
_load_errorattribute for error messages - Added
load_statusandload_errorproperties - Modified
load()to wrap_do_load()with proper error handling - Subclasses should implement
_do_load()instead ofload()
- Added
- Key Mapping: File-based sources (YAML, JSON, TOML) use recursive flattening
- Nested dictionaries are automatically flattened to dot notation (e.g.,
{"db": {"host": "localhost"}}→{"db.host": "localhost"}) - Consistent with existing key mapping rules (
__→.,_preserved, lowercase)
- Nested dictionaries are automatically flattened to dot notation (e.g.,
- Examples: Updated all examples to use best practices
- Use nested dataclasses instead of double-underscore fields
- Include field descriptions in metadata
- Proper error handling with
RequiredFieldError - Support for
--helpand-cvflags
Fixed
- Fixed "Unknown" status in diagnostic table for Env, CLI, Defaults, and DotEnv sources
- Fixed source status tracking to correctly show "Active", "Not Available", or "Failed" status
- Improved test coverage for file-based sources and multiple sources of the same type
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependenciesRelease v0.4.0
Changed
- Updated Python version support to 3.8-3.14
- Integrated CI workflow with uv for automated testing and building
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependenciesRelease v0.3.0
Added
- Etcd Source Enhancements:
- TLS/SSL certificate support for secure connections
- User authentication support
from_env()method for configuration from environment variables- Comprehensive watch support for dynamic configuration updates
- Full integration with ConfigStore and subscribe mechanism
- UV Dependency Management:
- Migrated from conda to uv for faster dependency management
- Added
setup-venvcommand for CI/CD workflows (dependencies only) - Automatic uv detection with fallback to pip
- Documentation:
- Complete etcd source documentation in Sphinx
- Comprehensive watch and dynamic updates examples
- Contributing guidelines (CONTRIBUTING.md)
- UV setup guide (UV_SETUP.md)
- Quick setup guide (SETUP.md)
- PrettyTable Integration: Diagnostic tables now use
prettytablelibrary for better formatted ASCII tables - Standard CLI Options: All varlord-based applications now support standard command-line options:
--help, -h: Show help message and exit--check-variables, -cv: Show diagnostic table of all configuration variables and exit
- Enhanced Diagnostic Table:
--check-variablesnow displays two comprehensive tables:- Variable Status Table: Shows all configuration variables with their status (Required/Optional, Loaded/Missing, Source, Value)
- Source Information Table: Shows detailed source diagnostics including:
- Priority order (1 = lowest, higher numbers = higher priority)
- Source name (from source.name property)
- Instance (source string representation via str(source))
- Load time in milliseconds (for performance diagnostics)
- Watch support status (Yes/No)
- Last update time (N/A for now, extensible for future use)
- Improved Help Output: Help text now includes standard options section at the beginning
- Source Load Time Measurement: Automatic measurement of source load times for performance diagnostics
Changed
- Help Output: Removed "Configuration Source Priority" section from help output (moved to
--check-variablesfor better visibility) - Diagnostic Output:
--check-variablesnow provides comprehensive source diagnostics in addition to variable status - Dependencies: Added
prettytable>=3.0.0as a core dependency for better table formatting
Fixed
- Fixed
Env.__repr__()to reflect model-based filtering (removed outdatedprefixreference) - Improved error messages when required fields are missing in
--check-variablesmode
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependenciesRelease v0.2.0
Added
- Explicit Required/Optional Configuration: All fields must explicitly specify
required=Trueoroptional=Truein metadata. No inference allowed. - Automatic Model Defaults: Model defaults are automatically applied as base layer. No need to explicitly include
sources.Defaultsin sources list. - Model-Driven Source Filtering: All sources (Env, CLI, DotEnv, Etcd) now filter variables/arguments based on model fields. Only model-defined fields are loaded.
- Required Field Validation: New
Config.validate()method to validate required fields independently.Config.load()now has optionalvalidateparameter. - Comprehensive Error Messages: When required fields are missing, error messages include:
- List of missing fields with descriptions
- Source mapping rules and examples for each active source
- Actionable guidance on how to provide missing parameters
- Field Metadata Support: Support for
descriptionandhelpin field metadata for better documentation and CLI help text. - New Modules:
varlord.metadata: Field information extraction and utilitiesvarlord.validation: Model definition validation and configuration validationvarlord.source_help: Source mapping examples and error message formatting
Changed
- BREAKING:
Envsource no longer acceptsprefixparameter. All environment variables are filtered by model fields. - BREAKING: All fields must have explicit
requiredoroptionalmetadata.ModelDefinitionErroris raised if missing. - BREAKING:
Config.from_model()no longer acceptsenv_prefixparameter. - BREAKING:
Defaultssource is now internal. Model defaults are automatically applied, no need to include in sources list. - BREAKING: Empty strings and empty collections are now considered valid values for required fields (only presence is checked, not emptiness).
Fixed
- Improved error messages for missing required fields
- Better CLI help text with field descriptions
- Consistent model filtering across all sources
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependenciesRelease v0.1.0
Added
- Comprehensive tutorial
- Comprehensive documentation
Installation
pip install varlordOr with optional dependencies:
pip install varlord[dotenv] # For .env file support
pip install varlord[etcd] # For etcd support
pip install varlord[all] # All optional dependencies