Skip to content

bug: Generic class signatures never show their type parameters #350

Backlog

Description

@chuckwondo

Description of the bug

With show_signature_type_parameters: true, a generic function's signature shows its type parameters (first[T](items)), but a generic class's signature never does. A class without __init__ gets no signature at all, and a class whose __init__ is merged into it gets Pair(first, second). The option's documentation says it shows "the type parameters in generic classes, methods, functions and type aliases signatures".

For example, the page for a generic protocol class Parser[T](Protocol) shows the heading Parser, while its parse method returns Sequence[T], so the page uses a T that it never introduces.

To Reproduce

mkdir -p repro/docs && cd repro
cat > generics.py <<'EOF'
class Box[T]:
    """A generic class without `__init__`."""


class Pair[T]:
    """A generic class with `__init__`."""

    def __init__(self, first: T, second: T) -> None:
        """Make a pair."""


def first[T](items: list[T]) -> T:
    """Return the first item."""
EOF
cat > mkdocs.yml <<'EOF'
site_name: repro
plugins:
  - mkdocstrings:
      handlers:
        python:
          paths: [.]
          options:
            separate_signature: true
            show_signature_type_parameters: true
            merge_init_into_class: true
EOF
echo '::: generics' > docs/index.md
uvx --python 3.13 --with 'mkdocstrings[python]' mkdocs build -q
grep doc-signature site/index.html | sed 's/<[^>]*>//g; s/^ *//'

Output:

Pair(first, second)
first[T](items)

Full traceback

None. The build succeeds without warnings.

Expected behavior

Each class signature shows its type parameters, as the function's does: Box[T] and Pair[T](first, second).

Environment information

python -m mkdocstrings_handlers.python._internal.debug
  • System: macOS-27.0.1-arm64-arm-64bit-Mach-O
  • Python: cpython 3.13.15
  • Environment variables:
  • Installed packages:
    • mkdocstrings-python v2.0.11

Additional context

The other versions are mkdocs 1.6.1, mkdocstrings 1.0.8, and griffelib 2.4.1.

Setting separate_signature: false moves the signatures into the headings, which render as Box, Pair(first, second), and first[T](items), so the class headings lack the type parameters too.

Activity

  1. added
    bug
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions