Summary
Example
(Playground: https://play.ty.dev/d92d2eb5-5007-4bc5-954c-be5018137ab6)
from collections.abc import Iterable
def check(obj: str | bytes) -> bool:
return True # TODO
iter_strings: Iterable[str] = iter('foobarbaz')
iter_strings = filter(check, iter_strings)
Expected behavior
No errors.
Actual behavior
Object of type `filter[str | bytes]` is not assignable to `Iterable[str]` (invalid-assignment) [Ln 9, Col 16]
Notes
I suspect that this has to do with #2799 and #2572, in that type info of iterable items is lost/overridden after being passed to a callable which takes another callable operating on said items. #1970 also reported pathological behaviors with filter() and map(), but the failure pattern was different there.
Version
ty 0.0.34 (d00448e 2026-05-01)
Summary
Example
(Playground: https://play.ty.dev/d92d2eb5-5007-4bc5-954c-be5018137ab6)
Expected behavior
No errors.
Actual behavior
Notes
I suspect that this has to do with #2799 and #2572, in that type info of iterable items is lost/overridden after being passed to a callable which takes another callable operating on said items. #1970 also reported pathological behaviors with
filter()andmap(), but the failure pattern was different there.Version
ty 0.0.34 (d00448e 2026-05-01)