Skip to content

Document generic parameters of generic classes #150319

@JelleZijlstra

Description

@JelleZijlstra

Documentation

PEP-585 introduced native generic support several years ago by adding the __class_getitem__ method. But all docstrings for C-implemented __class_getitem__ methods are just "See PEP 585", and the online documentation has nothing to say about this.

When a class is generic, we should tell users what it is generic over, so that those who wish to use types can understand what type parameters to use.

In the online documentation, any generic class should have a note like "This class is generic [link to docs about generics] and takes N type parameters, representing respectively ...".

The docstring for the __class_getitem__ method should similarly outline what the type parameters are.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions