Skip to content

Remove stale keys when reloading YAML sources - #209

Open
Imkkey wants to merge 2 commits into
beetbox:mainfrom
Imkkey:fix/yaml-reload-stale-keys-20261006
Open

Imkkey wants to merge 2 commits into
beetbox:mainfrom
Imkkey:fix/yaml-reload-stale-keys-20261006

Conversation

@Imkkey

@Imkkey Imkkey commented Oct 6, 2026 •

Copy link
Copy Markdown

Configuration.reload() rereads YAML sources with dict.update(), so keys removed from a file remain in memory. Deleted overrides continue to mask lower-priority defaults, and empty files or deleted optional files retain all previous settings. Reordering a file also leaves the old key order in place.

Clear the source after successfully loading and validating the replacement mapping, then populate it with the new contents. Keep the same source object and metadata. Parse errors, invalid non-mapping documents, and missing required files still leave the previous contents intact.

Add regression coverage for deleted overrides falling back to defaults, removal of keys without defaults, empty documents, optional-file deletion and recreation, key order, source identity and metadata, and preserving existing data on failed reloads. In-memory configuration sources remain unchanged.

Validation on Python 3.12.14:

  • The original six regression cases fail on unchanged upstream. The follow-up adds five invalid-root regressions that fail on the previous head, plus explicit null/~ controls; all 16 added cases pass on c523030.
  • All 36 YAML tests and 315 core tests pass.
  • Full suite: 316 passed, one existing failure in test_bump_version_applies_sequential_changelog_updates. Clean upstream has the same failure (300 passed, one failed): its expected changelog underline is fixed at 26 characters, while the October heading requires 24. The untouched previous PR head also reproduces it (309 passed, one failed).
  • Ruff lint/format, mypy with the CI Python 3.10 target, strict Sphinx build, changelog formatting/lint, and git diff --check pass.
  • Remote Test and Lint workflows for this head are action_required, awaiting maintainer approval, with zero jobs executed. Remote CI has not passed.

Prepared and checked with OpenAI Codex assistance.

@Imkkey Imkkey left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source review found one reload failure-preservation gap. This case has not been runtime-tested.

Comment thread confuse/sources.py
@Imkkey
Imkkey marked this pull request as ready for review October 14, 2026 06:22

This branch has not been deployed

No deployments
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