Message391203
> 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:23 | larry | set | recipients:
+ larry, gvanrossum, barry, eric.smith, methane, JelleZijlstra, xtreak, kj |
2021-04-16 14:17:23 | larry | set | messageid: <1618582643.55.0.0510121198283.issue43817@roundup.psfhosted.org> |
2021-04-16 14:17:23 | larry | link | issue43817 messages |
2021-04-16 14:17:23 | larry | create | |
|