python-sphinx/render-typing-Annotated-correctly-with-Python-3.10.patch

27 lines
1.0 KiB
Diff

From b82d3ef05a75b6dad9679f8746db5ef89785c7c0 Mon Sep 17 00:00:00 2001
From: Takeshi KOMIYA <i.tkomiya@gmail.com>
Date: Sun, 29 Aug 2021 15:40:49 +0900
Subject: [PATCH] Fix #9589: autodoc: typing.Annotated has wrongly been
rendered
At the HEAD of 3.10, the implementation of `typing.Annotated` has
been changed to have __qualname__.
---
CHANGES | 4 ++--
sphinx/util/typing.py | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index df5277ae7b..35f808211b 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -306,6 +306,8 @@ def stringify(annotation: Any) -> str:
return 'None'
elif annotation in INVALID_BUILTIN_CLASSES:
return INVALID_BUILTIN_CLASSES[annotation]
+ elif str(annotation).startswith('typing.Annotated'): # for py310+
+ pass
elif (getattr(annotation, '__module__', None) == 'builtins' and
getattr(annotation, '__qualname__', None)):
return annotation.__qualname__