sphinx-doc / sphinx-doc/sphinx
AnyStr parameter of generic base class not rendered by `:show-inheritance:`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
(This may be the same bug as #10564, but I'm reporting it separately just in case.)
When using autodoc to render a class that inherits Generic[Foo] and the :show-inheritance: option is given, if the generic type parameter is AnyStr, then the rendered HTML will just show "Bases: Generic" instead of "Bases: Generic[AnyStr]". Compare this to classes that inherit Generic[T], where T is a TypeVar; these are correctly rendered with "Bases: Generic[T]".
How to Reproduce
$ git clone https://github.com/jwodder/sphinx-bug-20220617
$ cd sphinx-bug-20220617
$ tox -e docs
$ # Open docs/_build/html/index.html and see that the base class for `AnyStrable` lacks the `AnyStr` parameter
Expected behavior
If a class inherits Generic[AnyStr], the base classes shown with :show-inheritance: should show "Generic[AnyStr]", not just "Generic".
Your project
https://github.com/jwodder/sphinx-bug-20220617
Screenshots
OS
macOS 11.6.6
Python version
3.9.13
Sphinx version
5.0.2
Sphinx extensions
sphinx.ext.autodoc, sphinx.ext.intersphinx
Extra tools
No response
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Clone the linked reproduction project and run tox -e docs; inspect docs/_build/html/index.html for the AnyStrable inheritance output. Trace the Sphinx autodoc path that renders :show-inheritance: bases, compare it with the Generic[T] case, and verify that the generated HTML shows Generic[AnyStr].
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100