Message399664
> 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. |
|
Date |
User |
Action |
Args |
2021-08-16 18:06:27 | mhils | set | recipients:
+ mhils, gvanrossum, kj |
2021-08-16 18:06:27 | mhils | set | messageid: <1629137187.01.0.70272924859.issue44926@roundup.psfhosted.org> |
2021-08-16 18:06:27 | mhils | link | issue44926 messages |
2021-08-16 18:06:26 | mhils | create | |
|