Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Created May 6, 2019 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lovasoa/74ea62a89f5bf073b0e0c2f222008ae3 to your computer and use it in GitHub Desktop.
Save lovasoa/74ea62a89f5bf073b0e0c2f222008ae3 to your computer and use it in GitHub Desktop.
typing.get_type_hints fails when used with a class defined in a documentation test
#!/usr/bin/env python3 -m doctest
from __future__ import annotations
import typing
def f(clazz):
"""
>>> class MyClass:
... pass
>>> class MyOtherClass:
... my_field: MyClass
>>> f(MyOtherClass)
"""
typing.get_type_hints(clazz)
#!/usr/bin/env python3 -m doctest
import typing
def f(clazz):
"""
>>> class MyClass:
... my_field: 'MyClass'
>>> f(MyClass)
"""
typing.get_type_hints(clazz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment