Skip to content

Fix update() storing dotted keys literally in box_dots mode - #357

Merged
cdgriffith merged 1 commit into
cdgriffith:developfrom
rahul05ranjan:update-dots-paths
Nov 13, 2026
Merged

cdgriffith merged 1 commit into
cdgriffith:developfrom
rahul05ranjan:update-dots-paths

Conversation

@rahul05ranjan

Copy link
Copy Markdown
Contributor

Description

Fixes #356.

With box_dots=True, update() bypassed the dotted-path semantics that __setitem__ and merge_update both apply, storing the key literally:

b = Box(default_box=True, box_dots=True)
b["x.y"] = 5        # -> {'x': {'y': 5}}
b.update({"x.z": 1})
# -> {'x': {'y': 5}, 'x.z': 1}   # literal parallel key

update() wrote through __convert_and_store directly, skipping the _parse_box_dots traversal. Box + Box was affected as well, since addition merges through update().

What changes

update() now routes keys that box_dots would treat as paths through __setitem__, the same way merge_update already stores. Everything else is unchanged: non-dotted keys keep the previous update behavior, and keys matched by box_dots_exclude stay literal, exactly as they do for direct assignment.

Validation Performed

  • 6 new tests in TestUpdateDottedPaths (test/test_box_keys_8.py): dotted-key nesting (fails on master), extending an existing path (fails on master), box_dots_exclude staying literal, kwargs dotted keys, non-dotted behavior unchanged, and Box + Box path merging (fails on master) — 3 fail on master, all pass with this change
  • Full suite: 675 passed + 16 failed with this change, identical to master (the 16 are toml/toml-w and ruamel-version artifacts on this host: ModuleNotFoundError-driven, unrelated to this change; toml/ruamel optional dependencies are not installable here)
  • Manual verification of box_dots_exclude literal keys through both update() and direct assignment (consistent)

This change was made with the help of an AI agent, which located the divergence between update/merge_update and wrote the patch and tests under my direction.

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>
cdgriffith added a commit that referenced this pull request Nov 11, 2026
@cdgriffith
cdgriffith changed the base branch from master to develop November 13, 2026 17:12
@cdgriffith
cdgriffith merged commit 456388f into cdgriffith:develop Nov 13, 2026
@cdgriffith cdgriffith mentioned this pull request Nov 13, 2026
@rahul05ranjan

Copy link
Copy Markdown
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

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.

box_dots: update() stores dotted keys literally instead of as paths (unlike __setitem__ and merge_update)

2 participants