The only use case I can come up with is something like:
``` @overload def filter(f: Callable[..., TypeGuard[int]], x: Sequence[object]) -> Sequence[int]: ... @overload def filter(f: Callable[..., bool], x: Sequence[object]) -> Sequence[object]: ... def filter(x): ... ```
Except that will work regardless of whether or not TypeGuard is a subtype of bool.
On Wed, Mar 17, 2021 at 5:47 PM Caleb Donovick email@example.com wrote:
Give me a concrete example of an overload you want to write but wouldn't be able to if `TypeGaurd` is considered a subtype of bool by type checkers. (again regardless of what type checkers think typeguard variables will be bools so `isinstance(guard, bool)` is going to be True and `isinstance(guard, TypeGuard)` is going to raise TypeError).
On Wed, Mar 17, 2021 at 5:41 PM Jake Bailey via Typing-sig < firstname.lastname@example.org> wrote:
Except then no existing function (like filter) could ever get a new overload with TypeGuard, because the compatibility would make it illegal, reducing it's usefulness. _______________________________________________ Typing-sig mailing list -- email@example.com To unsubscribe send an email to firstname.lastname@example.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: email@example.com