8686 'Text' ,
8787 'TypeAlias' ,
8888 'TypeAliasType' ,
89- 'TypeExpr ' ,
89+ 'TypeForm ' ,
9090 'TypeGuard' ,
9191 'TypeIs' ,
9292 'TYPE_CHECKING' ,
@@ -2047,23 +2047,30 @@ def f(val: Union[int, Awaitable[int]]) -> int:
20472047 """ )
20482048
20492049# 3.14+?
2050- if hasattr (typing , 'TypeExpr ' ):
2051- TypeExpr = typing .TypeExpr
2050+ if hasattr (typing , 'TypeForm ' ):
2051+ TypeForm = typing .TypeForm
20522052# 3.9
20532053elif sys .version_info [:2 ] >= (3 , 9 ):
2054- class _TypeExprForm (_ExtensionsSpecialForm , _root = True ):
2055- # TypeExpr (X) is equivalent to X but indicates to the type checker
2056- # that the object is a TypeExpr .
2054+ class _TypeFormForm (_ExtensionsSpecialForm , _root = True ):
2055+ # TypeForm (X) is equivalent to X but indicates to the type checker
2056+ # that the object is a TypeForm .
20572057 def __call__ (self , obj , / ):
20582058 return obj
20592059
2060- @_TypeExprForm
2061- def TypeExpr (self , parameters ):
2062- """Special typing form used to represent a type expression.
2060+ @_TypeFormForm
2061+ def TypeForm (self , parameters ):
2062+ """A special form representing the value that results from the evaluation
2063+ of a type expression. This value encodes the information supplied in the
2064+ type expression, and it represents the type described by that type expression.
2065+
2066+ When used in a type expression, TypeForm describes a set of type form objects.
2067+ It accepts a single type argument, which must be a valid type expression.
2068+ ``TypeForm[T]`` describes the set of all type form objects that represent
2069+ the type T or types that are assignable to T.
20632070
20642071 Usage:
20652072
2066- def cast[T](typ: TypeExpr [T], value: Any) -> T: ...
2073+ def cast[T](typ: TypeForm [T], value: Any) -> T: ...
20672074
20682075 reveal_type(cast(int, "x")) # int
20692076
@@ -2073,7 +2080,7 @@ def cast[T](typ: TypeExpr[T], value: Any) -> T: ...
20732080 return typing ._GenericAlias (self , (item ,))
20742081# 3.8
20752082else :
2076- class _TypeExprForm (_ExtensionsSpecialForm , _root = True ):
2083+ class _TypeFormForm (_ExtensionsSpecialForm , _root = True ):
20772084 def __getitem__ (self , parameters ):
20782085 item = typing ._type_check (parameters ,
20792086 f'{ self ._name } accepts only a single type' )
@@ -2082,13 +2089,20 @@ def __getitem__(self, parameters):
20822089 def __call__ (self , obj , / ):
20832090 return obj
20842091
2085- TypeExpr = _TypeExprForm (
2086- 'TypeExpr' ,
2087- doc = """Special typing form used to represent a type expression.
2092+ TypeForm = _TypeFormForm (
2093+ 'TypeForm' ,
2094+ doc = """A special form representing the value that results from the evaluation
2095+ of a type expression. This value encodes the information supplied in the
2096+ type expression, and it represents the type described by that type expression.
2097+
2098+ When used in a type expression, TypeForm describes a set of type form objects.
2099+ It accepts a single type argument, which must be a valid type expression.
2100+ ``TypeForm[T]`` describes the set of all type form objects that represent
2101+ the type T or types that are assignable to T.
20882102
20892103 Usage:
20902104
2091- def cast[T](typ: TypeExpr [T], value: Any) -> T: ...
2105+ def cast[T](typ: TypeForm [T], value: Any) -> T: ...
20922106
20932107 reveal_type(cast(int, "x")) # int
20942108
0 commit comments