Skip to content
Discussion options

You must be logged in to vote

You are correct, inheritance is not a supported way just like there is no switch from not required -> required. We lack a way to define a TypedDict partially.

Currently you have to define your TypedDict twice, once for each totality.
Functional vs. class definition does not make much of a difference. From you question I assume that you want to reuse a dict variable, e.g. Def = {"foo": int} and TypedDict("DefTotal", Def, total=True), while this would allow you to easily keep both dict types in sync it is not required for type-checkers to accept it (per PEP 589):

a variable that refers to a dictionary object does not need to be supported

Neither mypy not pyright allow dict variables and e…

Replies: 1 comment 1 reply

Comment options

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

Answer selected by andresdelfino
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