diff --git a/stdlib/collections/__init__.pyi b/stdlib/collections/__init__.pyi index b3b18d2ca..5f8200d5c 100644 --- a/stdlib/collections/__init__.pyi +++ b/stdlib/collections/__init__.pyi @@ -1,6 +1,6 @@ import sys from _collections_abc import dict_items, dict_keys, dict_values -from _typeshed import Self +from _typeshed import Self, SupportsLessThan, SupportsLessThanT from typing import Any, Dict, Generic, NoReturn, Tuple, Type, TypeVar, overload from typing_extensions import SupportsIndex, final @@ -77,9 +77,12 @@ class UserList(MutableSequence[_T]): def clear(self) -> None: ... def copy(self: _S) -> _S: ... def count(self, item: _T) -> int: ... - def index(self, item: _T, *args: Any) -> int: ... + def index(self, item: _T, __start: SupportsIndex = ..., __stop: SupportsIndex = ...) -> int: ... def reverse(self) -> None: ... - def sort(self, *args: Any, **kwds: Any) -> None: ... + @overload + def sort(self: UserList[SupportsLessThanT], *, key: None = ..., reverse: bool = ...) -> None: ... + @overload + def sort(self, *, key: Callable[[_T], SupportsLessThan], reverse: bool = ...) -> None: ... def extend(self, other: Iterable[_T]) -> None: ... _UserStringT = TypeVar("_UserStringT", bound=UserString) diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 4c1ea388b..63ca305a2 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -50,6 +50,7 @@ codecs.CodecInfo.streamreader codecs.CodecInfo.streamwriter collections.ChainMap.get # Adding None to the underlying Mapping Union messed up mypy collections.ChainMap.fromkeys # Runtime has *args which can really only be one argument +collections.UserList.sort # Runtime has *args but will error if any are supplied # Coroutine and Generator properties are added programmatically collections.abc.Coroutine.cr_await collections.abc.Coroutine.cr_code