Annotate UserList.sort() .index() arguments (#6472)

This commit is contained in:
Alex Waygood
2021-12-02 16:44:21 +00:00
committed by GitHub
parent 7b24e9d89a
commit a2e4a62fac
2 changed files with 7 additions and 3 deletions

View File

@@ -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)

View File

@@ -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