Skip to content

autodoc typehints do not create link for parametrized types #9194

@anntzer

Description

@anntzer

Describe the bug

autodoc typehints normally generate a link to the hinted type, but do not do so for parametrized types.

To Reproduce
Steps to reproduce the behavior:

$ cat >project.py <<EOF
from typing import Literal

def func(x: Literal["a", "b"], y: int):
    """
    :param x: The x.
    :param y: The y.
    """
EOF
sphinx-apidoc . -o . -F -A me -V 0.0 --extensions sphinx.ext.intersphinx
PYTHONPATH=. make O=-Dautodoc_typehints=description html

and open _build/html/project.html

Expected behavior
Literal (in the parameter description) should link to typing.Literal in CPython's docs, just like int does.

Your project
N/A

Screenshots
s

Environment info

  • OS: linux
  • Python version: 3.9.4
  • Sphinx version: 4.0.0
  • Sphinx extensions: intersphinx, autodoc
  • Extra tools: N/A

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions