MCPcopy Index your code
hub / github.com/python/cpython / NotRequired

Function NotRequired

Lib/typing.py:3436–3451  ·  view source on GitHub ↗

Special typing construct to mark a TypedDict key as potentially missing. For example:: class Movie(TypedDict): title: str year: NotRequired[int] m = Movie( title='The Matrix', # typechecker error if key is omitted year=1999,

(self, parameters)

Source from the content-addressed store, hash-verified

3434
3435@_SpecialForm
3436def NotRequired(self, parameters):
3437 """Special typing construct to mark a TypedDict key as potentially missing.
3438
3439 For example::
3440
3441 class Movie(TypedDict):
3442 title: str
3443 year: NotRequired[int]
3444
3445 m = Movie(
3446 title='The Matrix', # typechecker error if key is omitted
3447 year=1999,
3448 )
3449 """
3450 item = _type_check(parameters, f'{self._name} accepts only a single type.')
3451 return _GenericAlias(self, (item,))
3452
3453
3454@_SpecialForm

Callers 1

test_cannot_initMethod · 0.90

Calls 2

_type_checkFunction · 0.85
_GenericAliasClass · 0.85

Tested by 1

test_cannot_initMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…