From 227ed9f87a6c7af6128b5e2bb275834a9c2503b1 Mon Sep 17 00:00:00 2001 From: Gatsik <74517072+Gatsik@users.noreply.github.com> Date: Mon, 21 Jul 2025 19:38:42 +0300 Subject: [PATCH 1/3] Add `collections._tuplegetter` stub --- stdlib/collections/__init__.pyi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index bc33d91caa1d..54962bedb526 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -32,6 +32,13 @@ _VT = TypeVar("_VT") _KT_co = TypeVar("_KT_co", covariant=True) _VT_co = TypeVar("_VT_co", covariant=True) +@final +class _tuplegetter(Generic[_T]): # undocumented + @overload + def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ... + @overload + def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ... + # namedtuple is special-cased in the type checker; the initializer is ignored. def namedtuple( typename: str, From 8c2dcd69d2bc3b9956685dd5041c4d5a81339814 Mon Sep 17 00:00:00 2001 From: Gatsik <74517072+Gatsik@users.noreply.github.com> Date: Mon, 21 Jul 2025 23:24:18 +0300 Subject: [PATCH 2/3] Don't set default owner value for python3.9 --- stdlib/collections/__init__.pyi | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 54962bedb526..058279223676 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -34,10 +34,16 @@ _VT_co = TypeVar("_VT_co", covariant=True) @final class _tuplegetter(Generic[_T]): # undocumented - @overload - def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ... - @overload - def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ... + if sys.version_info >= (3, 10): + @overload + def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ... + @overload + def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ... + else: + @overload + def __get__(self, instance: None, owner: type[Any] | None) -> Self: ... + @overload + def __get__(self, instance: object, owner: type[Any] | None) -> _T: ... # namedtuple is special-cased in the type checker; the initializer is ignored. def namedtuple( From d1ef521d2f17673baf6b2bee2a899e69b0728006 Mon Sep 17 00:00:00 2001 From: Gatsik <74517072+Gatsik@users.noreply.github.com> Date: Tue, 22 Jul 2025 00:35:40 +0300 Subject: [PATCH 3/3] Apply suggestions from code review --- stdlib/collections/__init__.pyi | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index 058279223676..28f1a208c766 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -32,18 +32,21 @@ _VT = TypeVar("_VT") _KT_co = TypeVar("_KT_co", covariant=True) _VT_co = TypeVar("_VT_co", covariant=True) +# at runtime this class is implemented in _collections, but it considers itself to live in collections since Python 3.12 @final class _tuplegetter(Generic[_T]): # undocumented + def __init__(self, index: SupportsIndex, doc: str, /) -> None: ... + def __reduce__(self) -> tuple[type[Self], tuple[int, str]]: ... if sys.version_info >= (3, 10): @overload - def __get__(self, instance: None, owner: type[Any] | None = None) -> Self: ... + def __get__(self, instance: None, owner: type[Any] | None = None, /) -> Self: ... @overload - def __get__(self, instance: object, owner: type[Any] | None = None) -> _T: ... + def __get__(self, instance: object, owner: type[Any] | None = None, /) -> _T: ... else: @overload - def __get__(self, instance: None, owner: type[Any] | None) -> Self: ... + def __get__(self, instance: None, owner: type[Any] | None, /) -> Self: ... @overload - def __get__(self, instance: object, owner: type[Any] | None) -> _T: ... + def __get__(self, instance: object, owner: type[Any] | None, /) -> _T: ... # namedtuple is special-cased in the type checker; the initializer is ignored. def namedtuple(
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: