CKTIS / Python
typing.Required
Mark a TypedDict key as mandatory even when total=False makes the other keys omissible.
Version: Python 3.14; repository image, production runtime not attested
Syntax
job_id: Required[int]Mark a TypedDict key as mandatory even when total=False makes the other keys omissible.
Required controls the presence of the key for static checking, independently of whether its value type allows None. The runtime constructor still creates an ordinary dictionary without checking for missing keys.
Inspect the required-key metadata to see which field the schema requires.
Examples
from typing import Required, TypedDict
class Task(TypedDict, total=False):
job_id: Required[int | None]
note: str
print(sorted(Task.__required_keys__), sorted(Task.__optional_keys__))
print(Task(job_id=None), Task())
Result
['job_id'] ['note']
{'job_id': None} {}Inspect the required-key metadata to see which field the schema requires.