mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user