From faa7a9ad7cf93c75347a0eea1b000d9d8e49f3d8 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 2 Jan 2024 15:35:00 -0800 Subject: [PATCH] Move ellipsis definition to types --- stdlib/builtins.pyi | 12 ++++++++---- stdlib/types.pyi | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 6d2e219e0516..aaba33a28ff7 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1914,9 +1914,13 @@ def __import__( def __build_class__(__func: Callable[[], _Cell | Any], __name: str, *bases: Any, metaclass: Any = ..., **kwds: Any) -> Any: ... if sys.version_info >= (3, 10): - # In Python 3.10, EllipsisType is exposed publicly in the types module. - @final - class ellipsis: ... + from types import EllipsisType + + # Backwards compatibility hack for folks who relied on the ellipsis type + # existing in typeshed in Python 3.9 and earlier. + ellipsis = EllipsisType + + Ellipsis: EllipsisType else: # Actually the type of Ellipsis is , but since it's @@ -1925,7 +1929,7 @@ else: @type_check_only class ellipsis: ... -Ellipsis: ellipsis + Ellipsis: ellipsis class BaseException: args: tuple[Any, ...] diff --git a/stdlib/types.pyi b/stdlib/types.pyi index b26a668d273b..c91140fe0626 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -626,7 +626,10 @@ if sys.version_info >= (3, 10): @final class NoneType: def __bool__(self) -> Literal[False]: ... - EllipsisType = ellipsis # noqa: F821 from builtins + + @final + class EllipsisType: ... + from builtins import _NotImplementedType NotImplementedType = _NotImplementedType