21 Oct
2020
21 Oct
'20
5:40 p.m.
We talked about this on gitter, but I'll sum it up here as well. I think `filter` could be modified to use a guard: ``` @overload def filter(__function: Callable[[_T1], TypeGuard[_T2]], __iterable: Iterable[_T1]) -> Iterator[_T2]: ... ``` Unfortunately, you have to encode the narrowing behavior into the signature (as there's no code flow graph), but I suppose this makes some sense. `filterfalse`, not so much, because the way `TypeGuard` has to work only allows proving of truths. You mentioned TS's `Exclude`, which would allow proving of truths by having a `TypeGuard` that could say something like "I prove that the type of the first parameter is not of type `_T2`", for example.