Skip to content

Commit

Permalink
Merge pull request #9515 from tk0miya/9504_SpecialForm
Browse files Browse the repository at this point in the history
Fix #9504: autodoc: generate incorrect reference to the parent class
  • Loading branch information
tk0miya committed Aug 1, 2021
2 parents 1fd5f74 + d0c97e9 commit 650730d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions sphinx/util/typing.py
Expand Up @@ -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__)
Expand Down

0 comments on commit 650730d

Please sign in to comment.