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-24.07:51:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1619250694.69.0.882534696114.issue43817@roundup.psfhosted.org>
In-reply-to
Content
The difference between eval_str=True and eval_str=ONLY_IF_STRINGIZED:

def foo(a:int, b:"howdy howdy"): ...

inspect.get_annotations(foo, eval_str=True) throws an exception.
inspect.get_annotations(foo, eval_str=ONLY_IF_STRINGIZED) returns {'a': int, b: 'howdy howdy'}

Type hints have a convention that string annotations are a "forward declaration" and should be eval()uated.  Annotations don't have such a convention--a string is a legal annotation, and is not required to be valid Python.
History
Date User Action Args
2021-04-24 07:51:34larrysetrecipients: + larry, gvanrossum, barry, eric.smith, methane, lukasz.langa, JelleZijlstra, xtreak, kj
2021-04-24 07:51:34larrysetmessageid: <1619250694.69.0.882534696114.issue43817@roundup.psfhosted.org>
2021-04-24 07:51:34larrylinkissue43817 messages
2021-04-24 07:51:34larrycreate