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 JelleZijlstra, barry, eric.smith, gvanrossum, kj, larry, lukasz.langa, methane, xtreak
Date 2021-04-26.13:08:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I keep thinking about it, and I think letting inspect.get_annotations() and inspect.signature() raise exceptions is the right API choice.

I note that that's what typing.get_type_hints() did in Python 3.9.  During the development of Python 3.10, this was changed; typing.get_type_hints() started catching Exception and returning the original annotation dictionary (with un-eval'd strings).  This change has been reverted, and as of the current moment typing.get_type_hints() no longer catches exceptions on eval().

I think there are two types of people who will have string annotations that throw an exception when eval'd:

1) People who made a typo or other mistake.
2) People who deliberately use undefined identifiers in their annotations, due to circular import / circular dependencies in their code bases.

The people who are saying "just catch the exception and let it pass silently" seem to be in group 2.  I suggest that people in group 2 are sophisticated enough to start passing in eval_str=False to inspect.signature().  And I think people in group 1 would want to be alerted to their mistake, rather than have the library silently catch the error and mysteriously change its behavior.
Date User Action Args
2021-04-26 13:08:40larrysetrecipients: + larry, gvanrossum, barry, eric.smith, methane, lukasz.langa, JelleZijlstra, xtreak, kj
2021-04-26 13:08:40larrysetmessageid: <>
2021-04-26 13:08:40larrylinkissue43817 messages
2021-04-26 13:08:39larrycreate