On 8/10/21 11:15 AM, Thomas Grainger wrote:
Although the co_annoations code could intercept the NameError and replace return a ForwardRef object instead of the resolved name
No, it should raise a NameError, just like any other Python code. Annotations aren't special enough to break the rules.
I worry about Python-the-language enshrining design choices made by the typing module. Python is now on its fourth string interpolation technology, and it ships with three command-line argument parsing libraries; in each of these cases, we were adding a New Thing that was viewed at the time as an improvement over the existing thing(s). It'd be an act of hubris to assert that the current "typing" module is the ultimate, final library for expressing type information in Python. But if we tie the language too strongly to the typing module, I fear we could strangle its successors in their cribs.