Could you summarize your proposal in a few lines? I've tried to read that email several times now and I still don't follow the proposal. You can leave the reasoning *why* you believe your proposal is better out -- I just want to see what it will look like (how to define a type guard, and how to use it).
On Tue, Feb 16, 2021 at 11:39 AM Joseph Perez email@example.com wrote:
I've proposed PEP 593 `Annotated` too, but in the typing-sig mailing list: https://firstname.lastname@example.org/message/CVLLRWU7... and Guido had the following answer:
I see PEP 593 as a verbose solution to the problem "how do we use
annotations for static typing and for runtime metadata simultaneously". Type guards solve a problem that's entirely in the realm of static typing, so IMO it would be an abuse of Annotated.
(I've also written in the mail about checked cast as an alternative solution to type guard.)
For the most extensible approach both -> TypeGuard(...) and
-> Annotated[bool, TypeGuard(...)] could be allowed, which would open the path for future non-type-annotations, which could be used regardless of whether the code is type-annotated. I've proposed a possible implementation in my mail linked above. _______________________________________________ Python-Dev mailing list -- email@example.com To unsubscribe send an email to firstname.lastname@example.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://email@example.com/message/B3QZTPW6... Code of Conduct: http://python.org/psf/codeofconduct/