From 1c6ac09b822c55c5d37905499f7e25b075627955 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 14 Dec 2020 18:38:35 +0100 Subject: [PATCH] Add EllipsisType, NoneType, and NotImplementedType (Python 3.10) (#4822) --- stdlib/2and3/_typeshed/__init__.pyi | 11 +++++++---- stdlib/3/types.pyi | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/stdlib/2and3/_typeshed/__init__.pyi b/stdlib/2and3/_typeshed/__init__.pyi index 5e2d72ca8..5e3fe4a10 100644 --- a/stdlib/2and3/_typeshed/__init__.pyi +++ b/stdlib/2and3/_typeshed/__init__.pyi @@ -170,7 +170,10 @@ else: ReadableBuffer = Union[bytes, bytearray, memoryview, array.array, mmap.mmap, buffer] WriteableBuffer = Union[bytearray, memoryview, array.array, mmap.mmap, buffer] -# Used by type checkers for checks involving None (does not exist at runtime) -@final -class NoneType: - def __bool__(self) -> Literal[False]: ... +if sys.version_info >= (3, 10): + from types import NoneType as NoneType +else: + # Used by type checkers for checks involving None (does not exist at runtime) + @final + class NoneType: + def __bool__(self) -> Literal[False]: ... diff --git a/stdlib/3/types.pyi b/stdlib/3/types.pyi index 764dc5bd1..d5b419c17 100644 --- a/stdlib/3/types.pyi +++ b/stdlib/3/types.pyi @@ -15,6 +15,7 @@ from typing import ( Union, overload, ) +from typing_extensions import Literal, final # ModuleType is exported from this module, but for circular import # reasons exists in its own stub file (with ModuleSpec and Loader). @@ -324,3 +325,10 @@ if sys.version_info >= (3, 9): __parameters__: Tuple[Any, ...] def __init__(self, origin: type, args: Any) -> None: ... def __getattr__(self, name: str) -> Any: ... # incomplete + +if sys.version_info >= (3, 10): + @final + class NoneType: + def __bool__(self) -> Literal[False]: ... + EllipsisType = ellipsis # noqa F811 from builtins + NotImplementedType = _NotImplementedType # noqa F811 from builtins