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