Skip to content

support conditional fields on TypedDict and NamedTuple#2263

Open
carljm wants to merge 2 commits intopython:mainfrom
carljm:condfield
Open

support conditional fields on TypedDict and NamedTuple#2263
carljm wants to merge 2 commits intopython:mainfrom
carljm:condfield

Conversation

@carljm
Copy link
Copy Markdown
Member

@carljm carljm commented Apr 17, 2026

We reached consensus on this a while back in this Discuss thread, but I never got around to actually making the PR.

Seems like in the meantime we accidentally implemented the strict version of the check for TypedDict in ty, but astral-sh/ruff#24702 fixes that. Happy to wait a bit to land this if other type checkers want to have conforming implementations ready, too.

Comment thread docs/spec/typeddict.rst Outdated
@carljm carljm requested a review from davidhalter April 18, 2026 00:51
Copy link
Copy Markdown
Collaborator

@davidhalter davidhalter left a comment

Choose a reason for hiding this comment

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

Is it intentional that this is not specified for Protocol/Enums/Dataclasses? I would probably prefer this as a consistent change for all of these.

However I'm also good with this PR as a first step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: conformance tests Issues with the conformance test suite topic: typing spec For improving the typing spec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants