Summary
This might be a duplicate of one of the issues related to the constraint solver but couldn't tell which.
from collections.abc import Iterable, Iterator
class Unpacker[T: Iterable]:
def __iter__[S](self: "Unpacker[Iterable[S]]") -> Iterator[S]: ...
def integers() -> Unpacker[Iterable[int]]: ...
# OK
reveal_type(tuple(integers())) # Revealed type: `tuple[int, ...]`
for x in integers():
reveal_type(x) # Revealed type: `int
# NOT OK
reveal_type(list(integers())) # Revealed type: `list[Unknown]`
# Expected: `list[int]`
reveal_type(iter(integers())) # Revealed type: `Unknown`
# Expected: `Iterator[int]`
Playground
Version
ty 0.0.40
Summary
This might be a duplicate of one of the issues related to the constraint solver but couldn't tell which.
Playground
Version
ty 0.0.40