MCPcopy Index your code
hub / github.com/RustPython/RustPython / NotRequired

Function NotRequired

Lib/typing.py:3385–3400  ·  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

3383
3384@_SpecialForm
3385def NotRequired(self, parameters):
3386 """Special typing construct to mark a TypedDict key as potentially missing.
3387
3388 For example::
3389
3390 class Movie(TypedDict):
3391 title: str
3392 year: NotRequired[int]
3393
3394 m = Movie(
3395 title='The Matrix', # typechecker error if key is omitted
3396 year=1999,
3397 )
3398 """
3399 item = _type_check(parameters, f'{self._name} accepts only a single type.')
3400 return _GenericAlias(self, (item,))
3401
3402
3403@_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