Maximilian Hils <python-b...@maximilianhils.com> added the comment:
> For your specific use case (where the user is using Python 3.6), you could > pass in globalns and localns to get_type_hints as a temporary workaround. Off > the top of my head: get_type_hints(func2, globalns=foo.__dict__) might work. Would that work for your library? I guess the hard part is knowing that the type annotation comes from `foo`. In the example here we can of course hardcode it, but that doesn't work in the general case or for pdoc, the documentation generator I'm working on (https://pdoc.dev). I have experimented quite a bit with walking the AST to figure out where type aliases are imported from to then re-executing ForwardRefs with that globalns. Long story short, trying to reverse-engineer __forward_module__ quickly becomes a tangled hot mess where you need to adjust for import aliases, reimports, and so on. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44926> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com