v2.2.0
[2.2.0] - 2025-10-05
Added
- Plugin Architecture: Register custom data sources without modifying pydeflate code via
register_source(),get_source(),list_sources(), andis_source_registered(). - Context Management: New
PydeflateContextclass and context managers (pydeflate_session(),temporary_context()) for dependency injection, enabling multiple independent cache directories and thread-safe parallel operations. - Exception Hierarchy: Comprehensive custom exceptions including
PydeflateError(base),NetworkError,ConfigurationError,DataSourceError,CacheError,MissingDataError,SchemaValidationError, andPluginErrorfor fine-grained error handling. - Protocol Definitions: Explicit
SourceProtocol,DeflatorProtocol, andExchangeProtocolinterfaces inprotocols.pyfor better type safety and extensibility. - Schema Validation: Optional Pandera-based validation for IMF, World Bank, and OECD DAC data sources to catch data quality issues early (enable via
PYDEFLATE_ENABLE_VALIDATIONenvironment variable or context). - Property-Based Testing: Hypothesis tests verifying mathematical properties (deflation reversibility, exchange rate transitivity, rebasing invariants).
- Constants Module: Centralized constants in
constants.pyeliminating magic strings (PydeflateColumns,CurrencyCodes,DataSources, etc.). - Enhanced Caching: New
CacheManagerclass with thread-safe file locking viafilelockand platform-appropriate cache directories viaplatformdirs.
Fixed
- Corrected
to_current=Trueparameter behavior which was resulted in incorrect calculations
in certain edge cases.
Changed
- Build System: Migrated from Poetry to uv for faster dependency resolution and builds.
- Project Structure: Adopted src-based layout (
src/pydeflate/instead ofpydeflate/) following modern Python packaging best practices. - Python Version: Minimum required version increased from 3.10 to 3.11.
- Core Architecture: Rewrote
core/source.pywith cleaner abstractions and improvedSourceclass implementation. - Source Modules: Enhanced
sources/common.py,sources/dac.py,sources/imf.py, andsources/world_bank.pywith better error handling and validation. - Configuration: Expanded
pydeflate_config.pywithset_data_dir()function;set_pydeflate_path()now wrapsset_data_dir()for backward compatibility.
Improved
- Testing Infrastructure: Reorganized tests into
unit/,integration/,regression/, andproperty/directories with comprehensive fixtures inconftest.py. - Type Safety: Added type hints throughout the codebase and protocol definitions for better IDE support and static analysis.
- Error Messages: More descriptive error messages with source context and actionable guidance.
- Documentation: Added advanced usage examples in README covering error handling, plugin system, and context management.
- Code Quality: Consistent code formatting and linting with Ruff.
Removed
- Poetry configuration files (
poetry.lock,poetry.toml). - Obsolete test files (
tests/test_dac_deflator.py,tests/test_dac_totals.py,tests/test_wb_ppp_exchange.py), replaced by improved test suite.
by @jm-rivera in #28
Full Changelog: v.2.1.3...v2.2.0