ext.autodoc: fix formatting instance annotations

Currently `format_annotation` fails on instances, because instances don't have
`__module__` and `__qualname__` attributes.  Defer building the
`qualified_name` of an annotation until we have established that the annotation
is a type.
This commit is contained in:
Joost van Zwieten
2016-07-29 12:27:00 +02:00
parent da7e2d9dda
commit 099b58f7fe
4 changed files with 17 additions and 4 deletions

View File

@@ -46,3 +46,11 @@ def f7(x: Callable[[int, str], int]) -> None:
def f8(x: Tuple[int, str], y: Tuple[int, ...]) -> None:
pass
class CustomAnnotation:
def __repr__(self):
return 'CustomAnnotation'
def f9(x: CustomAnnotation(), y: 123) -> None:
pass