Repository navigation
Fix update() storing dotted keys literally in box_dots mode - #357
Merged
Merged
Conversation
update() wrote through __convert_and_store directly, skipping the _parse_box_dots traversal that __setitem__ applies, so a key such as 'x.z' was stored as a literal key in parallel to the nested x path — even when x already existed. merge_update already stores through __setitem__ and nests correctly; Box + Box merges through update() and was affected too. update() now routes keys that box_dots would treat as paths through __setitem__; everything else (non-dotted keys, or keys matched by box_dots_exclude) keeps the previous behavior. Fixes cdgriffith#356 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
Merged
Contributor
Author
|
Thank you for the review and the merge on both of these! Glad the dotted-key and BoxList fixes made it in together. Co-authored-by: rahul05ranjan 11793455+rahul05ranjan@users.noreply.github.com |
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.
Description
Fixes #356.
With
box_dots=True,update()bypassed the dotted-path semantics that__setitem__andmerge_updateboth apply, storing the key literally:update()wrote through__convert_and_storedirectly, skipping the_parse_box_dotstraversal.Box + Boxwas affected as well, since addition merges throughupdate().What changes
update()now routes keys thatbox_dotswould treat as paths through__setitem__, the same waymerge_updatealready stores. Everything else is unchanged: non-dotted keys keep the previousupdatebehavior, and keys matched bybox_dots_excludestay literal, exactly as they do for direct assignment.Validation Performed
TestUpdateDottedPaths(test/test_box_keys_8.py): dotted-key nesting (fails on master), extending an existing path (fails on master),box_dots_excludestaying literal, kwargs dotted keys, non-dotted behavior unchanged, andBox + Boxpath merging (fails on master) — 3 fail on master, all pass with this changetoml/toml-wand ruamel-version artifacts on this host:ModuleNotFoundError-driven, unrelated to this change; toml/ruamel optional dependencies are not installable here)box_dots_excludeliteral keys through bothupdate()and direct assignment (consistent)This change was made with the help of an AI agent, which located the divergence between
update/merge_updateand wrote the patch and tests under my direction.