Message391590
I think it gets a little murkier when we talk about *annotations* vs *type hints*. Type hints have a defined meaning for a string: a string is a sort of forward declaration, and you eval() the string to get the real value. (Or, not, if you're comfortable working with the stringized version of the type hint.) So typing.get_type_hints() calls eval() on *every* annotation value of type str.
But inspect.get_annotations() can't be so opinionated. If the user entered a string as their annotation, it should assume they want the string to show up in the annotations dict. This is why I'm trying to be so smart with the "eval_str" default value heuristic.
The text in the docs about a "future version of Python" is pursuant to my vague "PEP 1212" idea, which would let get_annotations() determine or not whether the annotations were stringized by the compiler. Or whatever we wind up deciding to do for Python 3.11--which, as you say, will hopefully disambiguate this question.
p.s. assuming you meant PEP 563, not PEP 573. |
|
Date |
User |
Action |
Args |
2021-04-22 11:47:06 | larry | set | recipients:
+ larry, gvanrossum, barry, eric.smith, methane, lukasz.langa, JelleZijlstra, xtreak, kj |
2021-04-22 11:47:06 | larry | set | messageid: <1619092026.45.0.736683540818.issue43817@roundup.psfhosted.org> |
2021-04-22 11:47:06 | larry | link | issue43817 messages |
2021-04-22 11:47:06 | larry | create | |
|