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

Function TypeForm

Lib/typing.py:907–928  ·  view source on GitHub ↗

A special form representing the value that results from the evaluation of a type expression. This value encodes the information supplied in the type expression, and it represents the type described by that type expression. When used in a type expression, TypeForm describes a set of

(self, parameters)

Source from the content-addressed store, hash-verified

905
906@_TypeFormForm
907def TypeForm(self, parameters):
908 """A special form representing the value that results from the evaluation
909 of a type expression.
910
911 This value encodes the information supplied in the type expression, and it
912 represents the type described by that type expression.
913
914 When used in a type expression, TypeForm describes a set of type form
915 objects. It accepts a single type argument, which must be a valid type
916 expression. ``TypeForm[T]`` describes the set of all type form objects that
917 represent the type T or types that are assignable to T.
918
919 Usage::
920
921 def cast[T](typ: TypeForm[T], value: Any) -> T: ...
922
923 reveal_type(cast(int, "x")) # int
924
925 See PEP 747 for more information.
926 """
927 item = _type_check(parameters, f'{self} accepts only single type.')
928 return _GenericAlias(self, (item,))
929
930
931@_SpecialForm

Callers 1

test_callMethod · 0.90

Calls 2

_type_checkFunction · 0.85
_GenericAliasClass · 0.85

Tested by 1

test_callMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…