sphinx-doc / sphinx-doc/sphinx

AnyStr parameter of generic base class not rendered by `:show-inheritance:`

Open
#10,567 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
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
Screen Shot 2022-06-17 at 09 52 17
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.