Skip to content

feat(config): merge custom config over packaged defaults - #188

Merged
EtienneWallet merged 4 commits into
developfrom
refactor/config_merge
Jun 9, 2026
Merged

feat(config): merge custom config over packaged defaults#188
EtienneWallet merged 4 commits into
developfrom
refactor/config_merge

Conversation

@EtienneWallet

@EtienneWallet EtienneWallet commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

A custom config file (provided via the MXOPS_CONFIG environment variable or a local mxops_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/NoOptionError when that value was later read.

Changes

  • _Config always loads the packaged default_config.ini first, then merges a custom config on top (per-option override, with untouched options and sections inherited from the defaults).
  • A custom config path supplied through the MXOPS_CONFIG environment variable is now usable: find_config_path() returns a Path, so loading no longer fails.
  • The default config is read with explicit UTF-8 encoding.
  • The merge precedence and the silent-fallback trade-off (a misspelled custom section/option falls back to the default rather than raising) are documented in the _Config docstring.

Testing

New tests/test_config.py (10 tests) covers:

  • Override applied; untouched options and sections inherited from the defaults.
  • [DEFAULT]-section option inheritance, override, and adding a brand-new option.
  • MXOPS_CONFIG env-var resolution returns a Path, and raises when the path is missing.
  • Full 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.

EtienneWallet and others added 4 commits June 9, 2026 11:54
…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.
@EtienneWallet
EtienneWallet merged commit baa1525 into develop Jun 9, 2026
@EtienneWallet
EtienneWallet deleted the refactor/config_merge branch June 9, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant