Skip to content

Missing type annotations in generic class description #10605

@francois-rozet

Description

@francois-rozet

Describe the bug

With autodoc_typehints = 'description', the parameter type annotations of the constructor (__init__) of generic classes are missing from the description.

How to Reproduce

With autodoc_typehints = 'description' in conf.py,

from typing import *

#: whatever
T = TypeVar('T')

class Dummy(Generic[T]):
    r"""
    Arguments:
        arg: missing type annotation
    """

    def __init__(self, arg: str):
        pass

results in

image

in which the type annotation is missing for the arg parameter.

Expected behavior

The type annotations should not be missing.

Your project

N/A

Screenshots

No response

OS

Ubuntu 20.04

Python version

3.8.10

Sphinx version

5.0.2

Sphinx extensions

sphinx.ext.autodoc

Extra tools

No response

Additional context

This issue is probably related to #8219 and #8142.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions