On Sat, 13 Feb 2021 at 07:11, Steven D'Aprano email@example.com wrote:
Without reading the PEP, how is anyone supposed to know that this returns a bool?
By looking at the name, or at the return statements in the body. These are expected to be really short. Tooling can certainly easily be taught what TypeGuard[...] means -- the whole *point* is to enable tooling (it provides an essential, albeit minor, piece of new functionality for type checkers).
On Sat, Feb 13, 2021 at 2:38 AM Paul Moore firstname.lastname@example.org wrote:
I have to agree here. I'm not a frequent user of type hints yet, but I am starting to have to maintain code that has type hints, and from a maintenance perspective, I have to say that this would be really hard to deal with. If I saw this for the first time "in the wild", I'd have no idea what to do with it.
Think of it as new syntax. Of course you have to learn it (or Google it). Is it easy to learn? I think so. Is it easy to recognize once you've seen and understood it once? Yes. Is it easy to use it correctly given an example? Yes again.