Skip to content

Commit

Permalink
Add test case for recently fixed enumerate regression (#12627)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Apr 19, 2022
1 parent 20b0b9b commit cf146f4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test-data/unit/check-selftype.test
Original file line number Diff line number Diff line change
Expand Up @@ -1196,3 +1196,27 @@ class C(Generic[T]):
for x, y in Z(self.a, self.b):
reveal_type((x, y)) # N: Revealed type is "Tuple[T`1, builtins.str]"
[builtins fixtures/tuple.pyi]

[case testEnumerateReturningSelfFromIter]
from typing import Generic, Iterable, Iterator, TypeVar, Tuple

T = TypeVar("T")
KT = TypeVar("KT")
VT = TypeVar("VT")
Self = TypeVar("Self")

class enumerate(Iterator[Tuple[int, T]], Generic[T]):
def __init__(self, iterable: Iterable[T]) -> None: ...
def __iter__(self: Self) -> Self: ...
def __next__(self) -> Tuple[int, T]: ...

class Dict(Generic[KT, VT]):
def update(self, __m: Iterable[Tuple[KT, VT]]) -> None: ...

class ThingCollection(Generic[T]):
collection: Iterable[Tuple[float, T]]
index: Dict[int, T]

def do_thing(self) -> None:
self.index.update((idx, c) for idx, (k, c) in enumerate(self.collection))
[builtins fixtures/tuple.pyi]

0 comments on commit cf146f4

Please sign in to comment.