MCPcopy Index your code
hub / github.com/python/typing / __class_getitem__

Method __class_getitem__

typing_extensions/src/typing_extensions.py:972–984  ·  view source on GitHub ↗
(cls, params)

Source from the content-addressed store, hash-verified

970
971 @typing._tp_cache
972 def __class_getitem__(cls, params):
973 if not isinstance(params, tuple) or len(params) < 2:
974 raise TypeError("Annotated[...] should be used "
975 "with at least two arguments (a type and an "
976 "annotation).")
977 allowed_special_forms = (ClassVar, Final)
978 if get_origin(params[0]) in allowed_special_forms:
979 origin = params[0]
980 else:
981 msg = "Annotated[t, ...]: t must be a type."
982 origin = typing._type_check(params[0], msg)
983 metadata = tuple(params[1:])
984 return _AnnotatedAlias(origin, metadata)
985
986 def __init_subclass__(cls, *args, **kwargs):
987 raise TypeError(

Callers

nothing calls this directly

Calls 2

get_originFunction · 0.85
_AnnotatedAliasClass · 0.85

Tested by

no test coverage detected