Skip to content

Fix union spillover dispatch on copied converters - #811

Closed
Aschenbath wants to merge 1 commit into
python-attrs:mainfrom
Aschenbath:fix/union-passthrough-copy
Closed

Aschenbath wants to merge 1 commit into
python-attrs:mainfrom
Aschenbath:fix/union-passthrough-copy

Conversation

@Aschenbath

@Aschenbath Aschenbath commented Oct 25, 2026 •

Copy link
Copy Markdown

Copying a converter configured with union passthrough leaves spillover handling bound to the original converter. A hook registered on the copy works for A but is ignored for int | A; copy(forbid_extra_keys=True) can also accept extra keys inside that union.

Make the union hook factory an extended factory so dispatch supplies the converter generating the hook. Spillover then uses the copy's hooks and settings. Regression tests cover copy() and deepcopy(), warmed caches followed by hook registration, strict field validation, and a copied JSON converter loading a custom datetime format. The strategy docs and changelog describe the corrected behavior.

Validation:

  • All 11 new regression scenarios fail before the fix and pass after it.
  • Full suite on CPython 3.13 / Windows: 1,071 passed, 22 skipped, 15 xfailed.
  • Ruff lint/format and Sphinx HTML with warnings treated as errors pass.
  • The documentation doctests have two existing Windows/POSIX path-output mismatches, reproduced before the code change; 251 of 253 examples pass.

The full upstream CI workflow passes on this exact commit in the fork: all 10 jobs, covering CPython 3.10–3.15, PyPy 3.10, lint, package verification, and 100% combined coverage. The upstream Read the Docs build also passes.

Developed with AI assistance.

@Aschenbath
Aschenbath marked this pull request as ready for review October 25, 2026 01:05
@Aschenbath

Copy link
Copy Markdown
Author

Closing this one myself: I opened too many PRs here in a short time, which isn't fair to your review queue — sorry about that. I'm leaving #827 and #822 open. If this fix is something you'd want, I'm happy to reopen or rebase it later.

@Aschenbath Aschenbath closed this Nov 4, 2026
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