Larry Hastings <la...@hastings.org> added the comment:
> 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? ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43817> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com