Allow reversed to take any object implementing __len__ and __getitem__ (#5820)

`reversed` is currently annotated as accepting either a `Sequence` or objects implementing the `__reversed__` protocol.
This however is too strict as, per its [docs](https://docs.python.org/3/library/functions.html#reversed), it can take any object that implements `__len__` and `__getitem__`.
This commit is contained in:
Bas van Beek authored and GitHub committed 2021-07-29 07:48:14 -07:00
1 parent 65b3a4b09d
commit 7c37d6117d
3 files changed
+11 -6

No files matched your search

+4 -4
View File
@@ -1,8 +1,8 @@
from typing import Sized, overload
from typing_extensions import Literal, Protocol
from _typeshed import SupportsLenAndGetItem
from typing import overload
from typing_extensions import Literal
class _Vector(Protocol, Sized):
def __getitem__(self, i: int) -> float: ...
_Vector = SupportsLenAndGetItem[float]
class AnnoyIndex:
f: int