feat(config): merge custom config over packaged defaults - #188
Merged
Conversation
…ement - Always load the packaged default_config.ini first, then layer custom config on top - Fixes MXOPS_CONFIG env-var path handling (was returning str, now returns Path) - Adds explicit UTF-8 encoding on default config read for consistency - Documents merge precedence and silent-fallback trade-off in docstring - Adds DEBUG log when custom config is loaded for traceability
…path resolution New tests in tests/test_config.py cover: - Config merge behavior: override applied, untouched options/sections inherited - Regression: MXOPS_CONFIG env-var path returns Path (not str) - [DEFAULT] section: inheritance, override, and new-option addition - Partial config fixture at tests/data/configs/partial_config.ini Addresses all major and minor issues from adversarial review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A custom config file (provided via the
MXOPS_CONFIGenvironment variable or a localmxops_config.ini) is now layered on top of the packaged defaults instead of fully replacing them. Users only need to specify the values they want to override; any option or section they omit is inherited from the defaults.Previously a custom config had to be self-contained — omitting a section or option caused
NoSectionError/NoOptionErrorwhen that value was later read.Changes
_Configalways loads the packageddefault_config.inifirst, then merges a custom config on top (per-option override, with untouched options and sections inherited from the defaults).MXOPS_CONFIGenvironment variable is now usable:find_config_path()returns aPath, so loading no longer fails._Configdocstring.Testing
New
tests/test_config.py(10 tests) covers:[DEFAULT]-section option inheritance, override, and adding a brand-new option.MXOPS_CONFIGenv-var resolution returns aPath, and raises when the path is missing.Config.get_config()singleton path with a custom config must not recurse (config resolution during construction would re-enter the singleton indefinitely).Full unit suite passes (319 tests); ruff, flake8, bandit clean; pylint 10.00/10.