Skip to content

Type inference: Mapping from TypedDict? #2007

Answered by erictraut
Pringauss asked this question in Q&A
Discussion options

You must be logged in to vote

To understand why your TypedDict isn't assignable to Mapping[str, float], check out this section of the typing spec. (Scroll down to the last bullet point in that section.)

There is a draft PEP 728 that proposes to add the concept of "closed TypedDicts" to the type system. Pyright has experimental support for this PEP if you want to play around with it. Here's what that looks like in the pyright playground.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Pringauss
Comment options

Answer selected by Pringauss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants