On 10/21/21 5:42 PM, Damian Shaw wrote:
Sorry for the naive question but why doesn't "TYPE_CHECKING" work under PEP 649?

I think I've seen others mention this but as the code object isn't executed until inspected then if you are just using annotations for type hints it should work fine?

Yes, it works fine in that case.


Is the use case wanting to use annotations for type hints and real time inspection but you also don't want to import the objects at run time?

If that's really such a strong use cause couldn't PEP 649 be modified to return a repr of the code object when it gets a NameError? Either by attaching it to the NameError exception or as part of a ForwardRef style object if that's how PEP 649 ends up getting implemented?

That's the use case.

Your proposal is one of several suggesting that type annotations are special enough to break the rules.  I don't like this idea. But you'll be pleased to know there are a lot of folks in the "suppress the NameError" faction, including Guido (IIUC).

See also this PR against co_annotations, proposing returning a new AnnotationName object when evaluating the annotations raises a NameError.

   https://github.com/larryhastings/co_annotations/pull/3


Cheers,


//arry/

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/O75ZCWHRCZEINYRO2QJFKKWXP4GW2WVM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to