-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
autodoc: Add support for PEP 695's explicit type aliases #11561
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
Comments
PR welcome! A |
Should we add a bit of guidance to this issue, for anyone who might attempt it? Like, where would they need to make code changes, or where would they start? |
Likely this would be a new |
There's a lot of types that render as |
PEP 695 introduces (at least what I've discovered) two problems:
|
Support was added in pyright / pylance via microsoft/pyright#6647 by treating a type alias definition the same as a regular assignment when it comes to docstrings. |
+1 |
Are you interested in creating a PR @nyoma-diamond? |
@AA-Turner While I'd like to, I unfortunately don't have sufficient time or knowledge of Sphinx's codebase to implement this myself. Just thought I'd chip in with some further details from my experience, as I imagine as usage of Python 3.12+ becomes more common this will likely start to become a prevalent issue, particularly given Mypy gained support for PEP 695 in v1.12 last October (and also especially in conjunction with the related issue #8934, which is relevant for Python 3.10+ and was given Mypy support in v0.930). If my time commitments lighten I might be able to take a peak into this and hack something together, but I don't suspect to get anywhere on that any time soon. |
Is your feature request related to a problem? Please describe.
sphinx cannot document
typing.TypeAliasType
nortyping_extensions.TypeAliasType
.https://peps.python.org/pep-0695/
Describe the solution you'd like
automodule
should document exportedTypeAliasType
s without needing a preceding#:
comment, the same way that classes and functions do not need a preceding#:
.References to such a type used in the signatures of other functions, types, classes, etc should hyperlink to the type's declaration, the same way that references to a class will hyperlink to the declaration of that class.
The declaration should render similar to how older style type aliases render today, saying "alias of ..."
Describe alternatives you've considered
Additional context
#8934
#11438
The text was updated successfully, but these errors were encountered: