[issue37835] typing.get_type_hints wrong namespace for forward-declaration of inner class

Netzeband report at bugs.python.org
Tue Aug 20 00:31:00 EDT 2019


Netzeband <andre at netzeband.eu> added the comment:

I tried my idea with the small example code above. However it does not work like expected: 
(see zipped example project, attached to this comment)

At the moment where the function decorator is applied to the method of the inner class, the local namespace ("locals()") does not contain any inner class. Even not another inner class, define before the corresponding class.

So the only way to get it working is to add the __locals__ attribute manually after defining the class, which is even more ugly than my suggested workaround with the function decorator :-(

Any further ideas about this?

----------
Added file: https://bugs.python.org/file48552/get_type_hints_for_inner_classes.zip

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37835>
_______________________________________


More information about the Python-bugs-list mailing list