Skip to content

Preserve wrapper identity during in-place dictionary union - #598

Open
Gonghan-Princess wants to merge 1 commit into
fabiocaccamo:mainfrom
Gonghan-Princess:codex/fix-inplace-union-identity
Open

Preserve wrapper identity during in-place dictionary union#598
Gonghan-Princess wants to merge 1 commit into
fabiocaccamo:mainfrom
Gonghan-Princess:codex/fix-inplace-union-identity

Conversation

@Gonghan-Princess

Copy link
Copy Markdown

Describe your changes

After b = benedict(source); b |= other, b currently becomes the underlying plain dict. Keypath access and the original wrapper identity are lost even though the source dictionary is updated correctly. For example, a wrapper configured with keypath_separator="/" can no longer resolve b["item/name"] after the union.

Keep the existing in-place update of the wrapped dictionary and return the wrapper itself. Add regressions for dictionary and key/value iterable inputs, both storage modes, source updates, and retained keypath configuration.

Related issue

Follow-up to #334: value updates were fixed there; this addresses the remaining loss of wrapper identity. All-state searches found no existing PR for that behavior.

Validation

  • Before the fix: three regression subcases failed; the two non-wrapping controls passed.
  • Focused modules: 125 tests passed.
  • Full Windows Python 3.12 suite: 885 tests run, 884 passed and 1 skipped; total coverage 98%.
  • Mypy 2.3.1 passed for all 64 source files; all configured pre-commit hooks passed, including pinned Ruff 0.15.20 and mypy 2.1.0.
  • Other OS/Python combinations remain for CI.

Checklist before requesting a review

  • I have performed a self-review of my code (Codex review; no human review claimed).
  • I have added tests for the proposed changes.
  • I have run the tests and there are not errors.

AI disclosure: OpenAI Codex investigated the bug, prepared the patch and tests, reviewed the diff, ran verification, and drafted this description. No third-party implementation was copied.

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