[issue42824] get_type_hints throws for local class reference

2021-01-04 Thread Guido van Rossum
Guido van Rossum added the comment: This is a known limitation. To get this to work you have to pass globals() and locals(): typing.get_type_hints(Test, globals(), locals()) -- nosy: +gvanrossum resolution: -> wont fix stage: -> resolved status: open -> closed

[issue42824] get_type_hints throws for local class reference

2021-01-04 Thread Fabian.M
New submission from Fabian.M : The following code throws with "NameError: name 'Nested' is not defined". For reference, it works well when moving class definitions out of the local scope. import typing T = typing.TypeVar('T') def test(): class Nested(typing.Generic[T]): pass