On 8/10/21 11:09 AM, Damian Shaw wrote:
Could PEP 649 be modified to say that if a NameError is raised the
result is not cached and therefore you can inspect it later at runtime
to get the real type once it is defined? Wouldn't that then allow
users to write code that allows for all use cases under this scenario?
The PEP doesn't say so explicitly, but that was the intent of the
design, yes. If you look at the pseudo-code in the "__co_annotations__"
section:
https://www.python.org/dev/peps/pep-0649/#co-annotations
you'll see that it doesn't catch NameError, allowing it to bubble up to
user code. The prototype intentionally behaves the same way. Certainly
it wouldn't hurt to mention that explicitly in the PEP.
//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/Q4QHBAXUUV3KVD2ZLMNZW3K64A6CQV7B/
Code of Conduct: http://python.org/psf/codeofconduct/