(original) (raw)

On Sat, Sep 22, 2018 at 11:29 AM Eric V. Smith <eric@trueblade.com> wrote:
I think this problem is endemic to get\_type\_hints(). I've never
understood how you're supposed to use the globals and locals arguments
to it, but this works:

print(get\_type\_hints(Bar.\_\_init\_\_, globals()))

as does:

print(get\_type\_hints(Bar.\_\_init\_\_, Bar.\_\_module\_\_))

But that seems like you'd have to know a lot about how a class were
declared in order to call get\_type\_hints on it. I'm not sure \_\_module\_\_
is always correct (but again, I haven't really thought about it).

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.

It's really tough to be at the intersection of three PEPs...
--
--Guido van Rossum (python.org/\~guido)