Fix Union MRO inheritance causing RecursionError#81
Merged
NiklasRosenstein merged 2 commits intodevelopfrom Apr 2, 2026
Merged
Fix Union MRO inheritance causing RecursionError#81NiklasRosenstein merged 2 commits intodevelopfrom
NiklasRosenstein merged 2 commits intodevelopfrom
Conversation
Add `inheritable` attribute to ClassDecoratorSetting (default True) and set it to False on Union, so Union settings are not inherited by subclasses through MRO traversal. This prevents infinite recursion when serializing/deserializing dataclasses registered as union members. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Use ClassVar for inheritable on both ClassDecoratorSetting and Union to satisfy mypy. Add unreleased changelog entry for #80. Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.
Summary
RecursionErrorwhen serializing/deserializing dataclasses using theUnionregistryinheritableattribute toClassDecoratorSetting(defaultTrue) and sets it toFalseonUnion, preventing Union settings from being inherited by subclasses through MRO traversalget_class_settings()forExtraKeysinheritance, but this inadvertently causedUnionto also be inherited, leading to infinite recursionTest plan
@Uniondecorator still works correctlyExtraKeysinheritance tests still pass (PR Fix ClassDecoratorSetting and get_class_settings to correctly handle __databind_settings__ on subclasses #77 behavior preserved)🤖 Generated with Claude Code