Make NewType a class in 3.10 (#6469)

This commit is contained in:
Alex Waygood
2021-12-03 12:33:44 +00:00
committed by GitHub
parent 7a24e71a9b
commit 050a77d8e3

View File

@@ -83,6 +83,15 @@ if sys.version_info >= (3, 10):
Concatenate: _SpecialForm = ...
TypeAlias: _SpecialForm = ...
TypeGuard: _SpecialForm = ...
class NewType:
def __init__(self, name: str, tp: type) -> None: ...
def __call__(self, x: _T) -> _T: ...
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...
__supertype__: type
else:
def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...
# These type variables are used by the container types.
_S = TypeVar("_S")
@@ -699,8 +708,6 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
def __or__(self: _T, __value: _T) -> _T: ...
def __ior__(self: _T, __value: _T) -> _T: ...
def NewType(name: str, tp: Type[_T]) -> Type[_T]: ...
# This itself is only available during type checking
def type_check_only(func_or_cls: _F) -> _F: ...