import typing class GlobalUnderTest(): def foo(a: 'GlobalUnderTest'): pass print(typing.get_type_hints(GlobalUnderTest.foo)) def working(): class A(): pass class UnderTest(): def foo(a: A): pass print(typing.get_type_hints(UnderTest.foo)) def not_working(): class UnderTest(): def foo(a: 'UnderTest'): pass # print(typing.get_type_hints(UnderTest.foo, localns=locals())) # this would work print(typing.get_type_hints(UnderTest.foo)) working() not_working()