Casting from a TypedDict
to a Mapping
can be a bit more lax
#9513
tusharsadhwani
started this conversation in
Ideas
Replies: 1 comment
-
The typing spec specifically disallows assignment to a more specific There is a draft PEP that defines support for "closed" TypedDicts. This PEP hasn't yet been approved, but pyright contains provisional support for the latest draft. You can try it by setting |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, this code fails type checking:
Changing the annotation of
v
toMapping[str, object]
works. But since the TypedDict only containsstr
fields, I think this cast should work? Is there a reason for the cast to not work right now?Beta Was this translation helpful? Give feedback.
All reactions