This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author levkivskyi
Recipients levkivskyi, lovasoa
Date 2019-05-10.19:42:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557517330.33.0.288333072813.issue36810@roundup.psfhosted.org>
In-reply-to
Content
I think this is related to doc tests being executed in a namespace where the class definition is not available. I am not sure what is the best way here, a workaround is to explicitly pass the namespace, for example this passes:

import typing
  
def f(clazz, ns):
    """
    >>> class MyClass:
    ...   my_field: 'MyClass'
    >>> f(MyClass, globals())
    """
    typing.get_type_hints(clazz, ns)

You can maybe make the ns parameter optional, but it still doesn't look like a good solution.
History
Date User Action Args
2019-05-10 19:42:10levkivskyisetrecipients: + levkivskyi, lovasoa
2019-05-10 19:42:10levkivskyisetmessageid: <1557517330.33.0.288333072813.issue36810@roundup.psfhosted.org>
2019-05-10 19:42:10levkivskyilinkissue36810 messages
2019-05-10 19:42:09levkivskyicreate