Repository navigation
Preserve nested mutable mappings in recursive merges - #453
Merged
Merged
Conversation
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.
Problem
A nested
UserDictorChainMapis treated differently from a nesteddictduring recursive merges. A small override replaces the entire mapping and loses unrelated settings. Withdefaults_deep, the existing mapping stays but missing defaults are not added. Customizers also never reach the nested entries.For example, merging
{"settings": UserDict({"host": "localhost", "timeout": 30})}with{"settings": {"timeout": 60}}currently dropshost.Change
Recognize any
Mappingsource paired with aMutableMappingdestination as a recursive mapping merge. Keep the destination mapping object, the existing literal-key lookup, source deep-copying, list behavior and scalar replacement rules. Add regression coverage for mixed dict/UserDict/ChainMap pairs, deep defaults, customizers, mappings nested in lists, ChainMap parent layers and source isolation. No dependencies or public signatures change.Validation
Base:
developatb6bd031de47134b8e3c3977fbe65bf13cc51a205.inv cibefore and after on Python 3.10: source/wheel builds, Sphinx with warnings as errors, Ruff format/lint, mypy, generated chaining-stub freshness and the configured tests pass.git diff --checkpasses.The documented test command excludes
tests/pytest_mypy_testing; source mypy and generated-stub checks are included. An initial broader exploratory collection included that optional directory and failed 334 assertions; those are not claimed as passing. Windows, macOS and hosted CI have not been run locally.Patch prepared and tests executed by Instinct, an AI assistant, at my request.