summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-08-01 15:13:27 +0900
committerGitHub <noreply@github.com>2021-08-01 15:13:27 +0900
commit650730d9b29de0776bc5cf845b153f89ac4fc302 (patch)
treebe41dd52c09ba89d6f87772fe5ab60256cc87a5c
parent1fd5f746539d3e02886032fae8d53af0c2f6ecdd (diff)
parentd0c97e9eb57126e38b7b018a101df1ecb1ad12b8 (diff)
downloadsphinx-git-650730d9b29de0776bc5cf845b153f89ac4fc302.tar.gz
Merge pull request #9515 from tk0miya/9504_SpecialForm
Fix #9504: autodoc: generate incorrect reference to the parent class
-rw-r--r--CHANGES2
-rw-r--r--sphinx/util/typing.py8
2 files changed, 4 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 70eb8db93..7332a40fb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -16,6 +16,8 @@ Features added
Bugs fixed
----------
+* #9504: autodoc: generate incorrect reference to the parent class if the target
+ class inherites the class having ``_name`` attribute
* #9512: sphinx-build: crashed with the HEAD of Python 3.10
Testing
diff --git a/sphinx/util/typing.py b/sphinx/util/typing.py
index 012d32e52..f856950bf 100644
--- a/sphinx/util/typing.py
+++ b/sphinx/util/typing.py
@@ -171,12 +171,8 @@ def _restify_py37(cls: Optional[Type]) -> str:
text += r"\ [%s]" % ", ".join(restify(a) for a in cls.__args__)
return text
- elif hasattr(cls, '_name'):
- # SpecialForm
- if cls.__module__ == 'typing':
- return ':obj:`~%s.%s`' % (cls.__module__, cls._name)
- else:
- return ':obj:`%s.%s`' % (cls.__module__, cls._name)
+ elif isinstance(cls, typing._SpecialForm):
+ return ':obj:`~%s.%s`' % (cls.__module__, cls._name)
elif hasattr(cls, '__qualname__'):
if cls.__module__ == 'typing':
return ':class:`~%s.%s`' % (cls.__module__, cls.__qualname__)