-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Report underlying type information for NewType and TypeVar #8460
Comments
Thank you for posting. I'll take a look at NewType from now on.
Now autodoc support to show attributes of TypeVar now. Do you know this? |
… is broken A custom type defined by typing.NewType was rendered as a function because the generated type is a function having special attributes. This renders it as a variable. Note: The module name where the NewType object defined is lost on generating it. So it is hard to make cross-reference for these custom types.
…NewType A custom type defined by typing.NewType was rendered as a function because the generated type is a function having special attributes. This renders it as a variable. Note: The module name where the NewType object defined is lost on generating it. So it is hard to make cross-reference for these custom types.
…NewType A custom type defined by typing.NewType was rendered as a function because the generated type is a function having special attributes. This renders it as a variable. Note: The module name where the NewType object defined is lost on generating it. So it is hard to make cross-reference for these custom types.
…NewType A custom type defined by typing.NewType was rendered as a function because the generated type is a function having special attributes. This renders it as a variable. Note: The module name where the NewType object defined is lost on generating it. So it is hard to make cross-reference for these custom types.
Fix #8460: autodoc: Support custom types defined by typing.NewType
Now I implement the support of NewTypes. It enables to render NewType variables in Sphinx. But referencing is still not working because NewType objects do not know where the type is defined. |
Additionally, I noticed |
Fix #8460: autodata directive does not display the detail of TypeVars
Now autodoc supports NewType variables. So I'm closing this. About better output for TypeVars, please let me know if you find a nice idea! |
Is your feature request related to a problem? Please describe.
Autodoc for NewType and TypeVar report the name of the type and the developer doc-comments but doesn't report the type metadata.
Describe the solution you'd like
For NewType I'd expect it to report the underlying type.
For example:
MyInt = NewType('MyInt', int) should report in the generated docs that the underlying type is int.
ForTypeVar there are multiple attributes. If there's bound type information, that should be reported. Additionally, it should report whether the type is invariant, covariant, or contravariant. As a bonus, cross-linking between invariant, covariant, or contravariant TypeVar declarations for the same underlying type.
Describe alternatives you've considered
The alternative would be for the developer to manually document the type information they've already declared - which seems redundant since this should be easy to resolve.
Additional context
The text was updated successfully, but these errors were encountered: