Skip to content

Commit 650730d

Browse files
authored
Merge pull request #9515 from tk0miya/9504_SpecialForm
Fix #9504: autodoc: generate incorrect reference to the parent class
2 parents 1fd5f74 + d0c97e9 commit 650730d

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Features added
1616
Bugs fixed
1717
----------
1818

19+
* #9504: autodoc: generate incorrect reference to the parent class if the target
20+
class inherites the class having ``_name`` attribute
1921
* #9512: sphinx-build: crashed with the HEAD of Python 3.10
2022

2123
Testing

sphinx/util/typing.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,8 @@ def _restify_py37(cls: Optional[Type]) -> str:
171171
text += r"\ [%s]" % ", ".join(restify(a) for a in cls.__args__)
172172

173173
return text
174-
elif hasattr(cls, '_name'):
175-
# SpecialForm
176-
if cls.__module__ == 'typing':
177-
return ':obj:`~%s.%s`' % (cls.__module__, cls._name)
178-
else:
179-
return ':obj:`%s.%s`' % (cls.__module__, cls._name)
174+
elif isinstance(cls, typing._SpecialForm):
175+
return ':obj:`~%s.%s`' % (cls.__module__, cls._name)
180176
elif hasattr(cls, '__qualname__'):
181177
if cls.__module__ == 'typing':
182178
return ':class:`~%s.%s`' % (cls.__module__, cls.__qualname__)

0 commit comments

Comments
 (0)