This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author larry
Recipients The Compiler, eric.smith, gvanrossum, kj, larry, levkivskyi
Date 2021-04-16.16:20:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1618590023.82.0.656456922038.issue43463@roundup.psfhosted.org>
In-reply-to
Content
> Hey Larry, it would seem that PEP 649 as currently specified would make it impossible to access annotations via the inspect module in cases where x.__annotations__ raises (because one of the annotations references an undefined variable).

That's true.  If PEP 649 is accepted, inspect.signature() might want to catch NameError when examining __annotations__ on the object.  Though I'm not sure what it should do when the exception is raised.


> I really think that we need *some* way of accessing partial annotations. Even just leaving the failing key out of __annotations__ (but keeping other keys if their annotation works) would be better than failing to return an __annotations__ dict at all.

Unfortunately I don't agree--"errors should never pass silently."  Silently omitting the failed annotation seems like it would be a bad experience.  What if the value you needed from the annotation was the one that was omitted?  Now you have a mystery obscuring your existing problem.

There is a PR against PEP 649 specifically to suppress NameErrors:

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

I haven't merged the PR as I don't agree with it.
History
Date User Action Args
2021-04-16 16:20:23larrysetrecipients: + larry, gvanrossum, eric.smith, The Compiler, levkivskyi, kj
2021-04-16 16:20:23larrysetmessageid: <1618590023.82.0.656456922038.issue43463@roundup.psfhosted.org>
2021-04-16 16:20:23larrylinkissue43463 messages
2021-04-16 16:20:23larrycreate