Why did PEP589 decide to make TypedDict
inconsistent with dict
?
#1729
Closed
randolf-scholz
started this conversation in
General
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I never really used
TypedDict
s before, but when I tried it, I immediately stumbled over the following:Trying to understand why, the PEP states:
But, this example makes no sense! The typing error should occur when calling
g(b)
, becausedict[str, int | str]
is incompatible withdict[str, int]
(and class, asB
isn't even a dict!)MutableMapping
s are invariant in both keys and values.It seems the real issue here is mutability, not that
dict
is incompatible withTypedDict
. It seems like a waste not being able to feed aTypedDict
into a pure function that acceptsdict
.Beta Was this translation helpful? Give feedback.
All reactions