Repository navigation
fix: preserve default-config key order in Configuration.dump - #200
Sanjays2402 wants to merge 2 commits into
Conversation
Configuration.dump documents that key order comes from the default configuration, but it builds its mapping from flatten(), which walks keys() in source-priority order. Any key present only in the defaults was therefore emitted after every key of the higher-priority user source, so a default key such as beets' paths could land inside a later section (reported as appearing under the Plugins header). Reorder the flattened mapping so keys declared by default sources come first, in their declared order, with remaining keys appended. Adds a regression test covering a user source that reorders keys.
|
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
|
Done — added a changelog entry under Unreleased for the fix ( |
Imkkey
left a comment
There was a problem hiding this comment.
I checked the interaction with full=False and redaction: default keys determine the output order without reintroducing omitted default-only values, and redacted values remain redacted. Multiple default sources with overlapping keys, empty or absent defaults, extra keys, nested mapping/list values and YAML comment sections also behaved correctly in the cases tested.
On 112aefb, the existing suite passed all 297 tests, and 21 additional focused checks passed. These were local checks on Python 3.12 against the PR's pinned base, not verification of GitHub Actions or integration with current main.
Closes #195
Configuration.dumpdocuments that key order comes from the default configuration, but it builds its mapping fromflatten(), which walkskeys()in source-priority order. A key present only in the defaults is therefore emitted after every key of the higher-priority user source — so in the reported casepaths(a default key) landed afterpluginsand appeared to be under the Plugins header.The dumped mapping now lists default-source keys first in their declared order, with any remaining keys appended. New
test_dump_follows_default_key_orderfails without the change and passes with it; the rest of the suite is unchanged (294 passed).