Skip to content

Support PEP 695 syntax for class definitions #11438

@JelleZijlstra

Description

@JelleZijlstra

PEP 695, which is implemented in the upcoming Python 3.12, adds a new syntax for defining generic classes:

class Sequence[T]:
     def __getitem__(self, idx: int) -> T: ...

I would like to document generic classes with e.g. .. class:: Sequence[T], but that doesn't render correctly (the class introduction doesn't appear):

Screen Shot 2023-05-22 at 8 34 55 PM

Presumably the parser for the class directive needs to be taught to recognize this syntax. (Cross-ref: python/cpython#104642 (comment).)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions