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, methane, xtreak
Date 2021-04-16.14:17:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Should this feature implemented in typing module? How about inspect module?

That's a reasonable idea.

Part of the reasoning behind putting it in the typing module was to share its implementation with typing.get_type_hints().  However, I was reading the source to typing.get_type_hints() yesterday, and its implementation is completely based on the assumption that the annotations are type hints.  It might be possible to rework its implementation to isolate these assumptions, but the remaining shared code would be probably less than fifty lines.  So the code reuse isn't a big deal.

If the two functions don't share an implementation, you're right, the inspect module is probably a better place for this new function.

> Additionally, how about adding `get_annotation_str()`, which returns str always? Some use cases (e.g. `help(f)`) need just string. I want to skip eval() in it.

I don't know if I'd want to add a third function.  Perhaps a parameter to get_annotation?  eval_str=True?
Date User Action Args
2021-04-16 14:17:23larrysetrecipients: + larry, gvanrossum, barry, eric.smith, methane, JelleZijlstra, xtreak, kj
2021-04-16 14:17:23larrysetmessageid: <>
2021-04-16 14:17:23larrylinkissue43817 messages
2021-04-16 14:17:23larrycreate