Skip to content

Support PEP 695 generics #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

viccie30
Copy link

@viccie30 viccie30 commented Jan 5, 2025

This builds on mkdocstrings/griffe#348 to document generic types, functions and type aliases.

The first commit makes a small change that the next commit builds upon. Because of the churn in tests, I've separated that commit.

I have added documentation, but not yet tests. This can probably only be merged once mkdocstrings/griffe#348 is merged.

@pawamoy
Copy link
Member

pawamoy commented Aug 19, 2025

I'll be working on this in the next few days, expect to see modifications coming in.

I wasn't fond of the new format_class and format_merged_init rendering utilities, because essentially what we want to do when merging the __init__ method into the class docs is to either:

  • concatenate the type parameters of both the class and init method:

    class Foo[T][U](param1: T, param2: U)

    ...but that might prevent formatting by Black/Ruff if it's invalid syntax (I'm not sure it is)

  • or actually merge/combine the type parameters together:

    class Foo[T, U](param1: T, param2: U)

    ...even if that's not entirely true, because as long as each type parameter cross-links to the right symbol, I think it's good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants