Skip to content

disallow TypedDict/Sequence/Dict unions#24

Merged
bentsku merged 2 commits intomainfrom
disallow-typed-dict-unions
Feb 27, 2026
Merged

disallow TypedDict/Sequence/Dict unions#24
bentsku merged 2 commits intomainfrom
disallow-typed-dict-unions

Conversation

@bentsku
Copy link
Copy Markdown

@bentsku bentsku commented Feb 27, 2026

When working on wrapped records, it was shown that we could not determine at runtime the type of such a record, or a typed dictionary. We cannot know what is contained, and how to deserialize the values contained in them.

So for this reason, we're disallowing such unions. We're also switching to a custom marker for TypedDict missing data, because we would create such union of dict | str manually. By using a custom marker, we can separate them, and in our logic, make sure to differentiate that case to drop the custom marker type.

The PR also reverts the runtime type for wrapped record, as we cannot have Unions with them anymore

@bentsku bentsku self-assigned this Feb 27, 2026
@bentsku bentsku marked this pull request as ready for review February 27, 2026 15:46
@bentsku bentsku requested a review from giograno February 27, 2026 15:46
Copy link
Copy Markdown
Member

@giograno giograno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great work 💯
I strongly approve the idea of being more strict in what we allow to serialize instead of allowing the world to come in ❗

@bentsku bentsku merged commit 3e49ba1 into main Feb 27, 2026
6 checks passed
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.

2 participants