From b9ad2e51203c7f965b8f83f607aa20c7e16b93a7 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Thu, 7 Nov 2024 22:27:32 -0800 Subject: [PATCH 1/5] Make builtins.type generic. --- stdlib/builtins.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index f4e0e0ffef39..e5d68352c641 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -167,7 +167,7 @@ class classmethod(Generic[_T, _P, _R_co]): @property def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... -class type: +class type(Generic[_T]): # object.__base__ is None. Otherwise, it would be a type. @property def __base__(self) -> type | None: ... From eb2d0468d3079cd71d0fefe403b105cdd590baa8 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Thu, 7 Nov 2024 22:59:44 -0800 Subject: [PATCH 2/5] Try using a TypeVar with a default. --- stdlib/builtins.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index e5d68352c641..53f0b748e368 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -98,6 +98,7 @@ _P = ParamSpec("_P") _StartT = TypeVar("_StartT", covariant=True, default=Any) _StopT = TypeVar("_StopT", covariant=True, default=Any) _StepT = TypeVar("_StepT", covariant=True, default=Any) +_TypeT = TypeVar('_TypeT', default=Any) class object: __doc__: str | None @@ -167,7 +168,7 @@ class classmethod(Generic[_T, _P, _R_co]): @property def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... -class type(Generic[_T]): +class type(Generic[_TypeT]): # object.__base__ is None. Otherwise, it would be a type. @property def __base__(self) -> type | None: ... From 92a75912e6abbc09814d00e8ec1738dd17eeb130 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 07:11:59 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/builtins.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 53f0b748e368..479b5570061c 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -98,7 +98,7 @@ _P = ParamSpec("_P") _StartT = TypeVar("_StartT", covariant=True, default=Any) _StopT = TypeVar("_StopT", covariant=True, default=Any) _StepT = TypeVar("_StepT", covariant=True, default=Any) -_TypeT = TypeVar('_TypeT', default=Any) +_TypeT = TypeVar("_TypeT", default=Any) class object: __doc__: str | None From bf2900cd79b3d5812c73e6fe0a733994d22be214 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Fri, 8 Nov 2024 09:14:35 -0800 Subject: [PATCH 4/5] Update stdlib/builtins.pyi Co-authored-by: Alex Waygood --- stdlib/builtins.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 479b5570061c..4e8ee7b48e28 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -98,7 +98,7 @@ _P = ParamSpec("_P") _StartT = TypeVar("_StartT", covariant=True, default=Any) _StopT = TypeVar("_StopT", covariant=True, default=Any) _StepT = TypeVar("_StepT", covariant=True, default=Any) -_TypeT = TypeVar("_TypeT", default=Any) +_TypeT_co = TypeVar("_TypeT_co", default=Any, covariant=True) class object: __doc__: str | None From f2c82b4928406107a182586f2a5f1a3848df41ee Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Fri, 8 Nov 2024 09:27:16 -0800 Subject: [PATCH 5/5] Update reference to old name. --- stdlib/builtins.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 4e8ee7b48e28..a2f56988bba2 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -168,7 +168,7 @@ class classmethod(Generic[_T, _P, _R_co]): @property def __wrapped__(self) -> Callable[Concatenate[type[_T], _P], _R_co]: ... -class type(Generic[_TypeT]): +class type(Generic[_TypeT_co]): # object.__base__ is None. Otherwise, it would be a type. @property def __base__(self) -> type | None: ...