Author netbnd
Recipients netbnd
Date 2019-08-13.09:36:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1565689003.91.0.0312877377737.issue37835@roundup.psfhosted.org>
In-reply-to
Content
When evaluating the type-hints of an inner-class (a class defined inside a function scope), the forward declaration does not work correctly. In this case the typing.get_type_hints does not get the right namespace, thus the class-string specified is not found.

When using the same syntax for a normal class (defined in global space) it works, or when using another class instead a forward declaration, also everything works.

As a workaround one could pass the local namespace (locals()) from the function where the class has been defined in to typing.get_type_hints. However in normal situations the typing.get_type_hints call is deep in the call hierarchy to do some runtime type-checks and at this point only the reference to the function-object is existing and no-one is aware of the fact, that this is just a method defined in a inner class.

From the outside perspective one would expect, that typing.get_type_hints reacts the same, independent of the type of class.
History
Date User Action Args
2019-08-13 09:36:43netbndsetrecipients: + netbnd
2019-08-13 09:36:43netbndsetmessageid: <1565689003.91.0.0312877377737.issue37835@roundup.psfhosted.org>
2019-08-13 09:36:43netbndlinkissue37835 messages
2019-08-13 09:36:43netbndcreate