Larry Hastings <[email protected]> added the comment:
> 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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue43463>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com