<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Sep 22, 2018 at 11:29 AM Eric V. Smith <<a href="mailto:eric@trueblade.com">eric@trueblade.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I think this problem is endemic to get_type_hints(). I've never <br>
understood how you're supposed to use the globals and locals arguments <br>
to it, but this works:<br>
<br>
print(get_type_hints(Bar.__init__, globals()))<br>
<br>
as does:<br>
<br>
print(get_type_hints(Bar.__init__, Bar.__module__))<br>
<br>
But that seems like you'd have to know a lot about how a class were <br>
declared in order to call get_type_hints on it. I'm not sure __module__ <br>
is always correct (but again, I haven't really thought about it).<br></blockquote><div><br></div><div>Still, I wonder if there's a tweak possible of the globals and locals used when exec()'ing the function definitions in dataclasses.py, so that get_type_hints() gets the right globals for this use case.</div><div><br></div><div>It's really tough to be at the intersection of three PEPs...<br></div><div> </div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div></div>