Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions stdlib/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ _VT = TypeVar("_VT")
_KT_co = TypeVar("_KT_co", covariant=True)
_VT_co = TypeVar("_VT_co", covariant=True)

@final
class _tuplegetter(Generic[_T]): # undocumented
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not likely to be needed, but for completeness:

Suggested change
class _tuplegetter(Generic[_T]): # undocumented
class _tuplegetter(Generic[_T]): # undocumented
def __init__(self, index: SupportsIndex, doc: str, /) -> None: ...
def __reduce__(self) -> tuple[type[Self], tuple[int, str]]: ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could mention that at runtime this class is implemented in _collections, but it considers itself to live in collections since Python 3.12

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: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__get__ doesn't accept keyword arguments at runtime:

Suggested change
@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: ...
@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(
typename: str,
Expand Down
Loading