" 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?
On Wed, Mar 17, 2021 at 4:58 PM Jake Bailey via Typing-sig < email@example.com> wrote:
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 -- firstname.lastname@example.org To unsubscribe send an email to email@example.com https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: firstname.lastname@example.org