total=Falseを指定したTypedDictで必須のキーを表す
Individual keys of a total=False TypedDict can be marked as required using Required:
https://docs.python.org/ja/3/library/typing.html#typing.TypedDict
It is also possible to mark all keys as non-required by default by specifying a totality of False:
「total=Falseはすべてのキーがnon-required」
code:ドキュメントの例.py
class Point2D(TypedDict, total=False):
x: Requiredint
y: Requiredint
label: str
RequiredはPython 3.11から可能
https://docs.python.org/ja/3/library/typing.html#typing.Required
PEP 655 – Marking individual TypedDict items as required or potentially-missing
3.10以前はtyping-extensionsで
total=TrueのTypedDictで必須でないキーを表す