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 mhils
Recipients gvanrossum, kj, mhils
Date 2021-08-16.18:06:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629137187.01.0.70272924859.issue44926@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2021-08-16 18:06:27mhilssetrecipients: + mhils, gvanrossum, kj
2021-08-16 18:06:27mhilssetmessageid: <1629137187.01.0.70272924859.issue44926@roundup.psfhosted.org>
2021-08-16 18:06:27mhilslinkissue44926 messages
2021-08-16 18:06:26mhilscreate