" because we can't tell when a TypeGuard has been assigned to a bool and then distinguish it later"
Why is this not preferable to a type error? Yes I can destroy type information by assigning a subtype value to a supertype variable but what makes `TypeGaurd[T]` so special that we don't ever want to risk losing its runtime type? Assumably I can assign a `TypeGuard[T]` to an object variable, why is this not also a problem?
Nothing about it is specific to TypeGuard, except that if TypeGuard is "compatible with bool", then it overlaps, and we get this behavior. It means that we can't rewrite existing functions in terms of TypeGuard, because we can't tell when a TypeGuard has been assigned to a bool and then distinguish it later. We have this issue already thanks to int/float conversions.
I agree that this is good to note in the PEP.
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: donovick@cs.stanford.edu