From b51c5bbd988f2571308f2de36403737807eeae32 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 23 Jul 2021 01:35:20 +0900 Subject: [PATCH] Fix #9490: autodoc: Some typing.* objects are broken At the HEAD of 3.10, the implementation of `typing._SpecialForm` and `typing._BaseGenericAlias` has been changed to support __qualname__. --- CHANGES | 2 ++ sphinx/util/typing.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index a4a4030711f..b4ebcf49826 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,8 @@ Bugs fixed * #9489: autodoc: Custom types using ``typing.NewType`` are not displayed well with the HEAD of 3.10 +* #9490: autodoc: Some objects under ``typing`` module are not displayed well + with the HEAD of 3.10 * #9435: linkcheck: Failed to check anchors in github.com Testing diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py index 4e1b184e0af..c57ed380de9 100644 --- a/sphinx/util/typing.py +++ b/sphinx/util/typing.py @@ -309,7 +309,7 @@ def stringify(annotation: Any) -> str: elif annotation in INVALID_BUILTIN_CLASSES: return INVALID_BUILTIN_CLASSES[annotation] elif (getattr(annotation, '__module__', None) == 'builtins' and - hasattr(annotation, '__qualname__')): + getattr(annotation, '__qualname__', None)): return annotation.__qualname__ elif annotation is Ellipsis: return '...'