Skip to content

Commit cf146f4

Browse files
authored
Add test case for recently fixed enumerate regression (#12627)
1 parent 20b0b9b commit cf146f4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test-data/unit/check-selftype.test

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,3 +1196,27 @@ class C(Generic[T]):
11961196
for x, y in Z(self.a, self.b):
11971197
reveal_type((x, y)) # N: Revealed type is "Tuple[T`1, builtins.str]"
11981198
[builtins fixtures/tuple.pyi]
1199+
1200+
[case testEnumerateReturningSelfFromIter]
1201+
from typing import Generic, Iterable, Iterator, TypeVar, Tuple
1202+
1203+
T = TypeVar("T")
1204+
KT = TypeVar("KT")
1205+
VT = TypeVar("VT")
1206+
Self = TypeVar("Self")
1207+
1208+
class enumerate(Iterator[Tuple[int, T]], Generic[T]):
1209+
def __init__(self, iterable: Iterable[T]) -> None: ...
1210+
def __iter__(self: Self) -> Self: ...
1211+
def __next__(self) -> Tuple[int, T]: ...
1212+
1213+
class Dict(Generic[KT, VT]):
1214+
def update(self, __m: Iterable[Tuple[KT, VT]]) -> None: ...
1215+
1216+
class ThingCollection(Generic[T]):
1217+
collection: Iterable[Tuple[float, T]]
1218+
index: Dict[int, T]
1219+
1220+
def do_thing(self) -> None:
1221+
self.index.update((idx, c) for idx, (k, c) in enumerate(self.collection))
1222+
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)