Improve UserList comparison methods (#6471)

These functions will fail at runtime if `other` is not either a `list` or a `UserList`. The elements within `other` must also be of the same type as the elements within `self`, or the comparison will fail.
This commit is contained in:
Alex Waygood
2021-12-02 15:19:50 +00:00
committed by GitHub
parent ddcef53af4
commit 7b24e9d89a

View File

@@ -51,10 +51,10 @@ class UserDict(MutableMapping[_KT, _VT]):
class UserList(MutableSequence[_T]):
data: list[_T]
def __init__(self, initlist: Iterable[_T] | None = ...) -> None: ...
def __lt__(self, other: object) -> bool: ...
def __le__(self, other: object) -> bool: ...
def __gt__(self, other: object) -> bool: ...
def __ge__(self, other: object) -> bool: ...
def __lt__(self, other: list[_T] | UserList[_T]) -> bool: ...
def __le__(self, other: list[_T] | UserList[_T]) -> bool: ...
def __gt__(self, other: list[_T] | UserList[_T]) -> bool: ...
def __ge__(self, other: list[_T] | UserList[_T]) -> bool: ...
def __contains__(self, item: object) -> bool: ...
def __len__(self) -> int: ...
@overload