-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Missing type annotations in generic class description #10605
Comments
I came across a similar issue with Basically, the resolution doesn't work for constructors when from __future__ import annotations
import typing as t
class Dummy():
r"""
Arguments:
arg: missing type annotation
"""
def __init__(self, arg: t.Optional[str]):
pass will also end up with a wrong type hint. In this case, it will be |
Constructor annotations where not properly detected in autodoc when `autodoc_typehints` was `'description'` or `'both'`.
Constructor annotations where not properly detected in autodoc when `autodoc_typehints` was `'description'` or `'both'`.
Constructor annotations where not properly detected in autodoc when `autodoc_typehints` was `'description'` or `'both'`.
Constructor annotations where not properly detected in autodoc when `autodoc_typehints` was `'description'` or `'both'`.
Hello @robsdedude, thanks for your PR, I hope it gets merged!
|
Yeah, I just realized 🙈 I'm sorry. |
Constructor annotations where not properly detected in autodoc when `autodoc_typehints` was `'description'` or `'both'`.
Constructor annotations where not properly detected in autodoc when `autodoc_typehints` was `'description'` or `'both'`.
So sorry for the pings. I'll change the commit message now for good. |
@francois-rozet is this now resolved? |
Hello @AA-Turner, yes. I tried with a more recent version of Sphinx (6.1.3) and it seems to be resolved. T = TypeVar('T')
class Dummy(Generic[T]):
r"""Dummy class.
Arguments:
arg: missing type annotation
"""
def __init__(self, arg: str):
pass results in The type is not missing anymore. |
@AA-Turner do you reckon it's worth splitting #10605 (comment) into a separate issue as it's not been resolved yet? |
Please do! |
Describe the bug
With
autodoc_typehints = 'description'
, the parameter type annotations of the constructor (__init__
) of generic classes are missing from the description.How to Reproduce
With
autodoc_typehints = 'description'
inconf.py
,results in
in which the type annotation is missing for the
arg
parameter.Expected behavior
The type annotations should not be missing.
Your project
N/A
Screenshots
No response
OS
Ubuntu 20.04
Python version
3.8.10
Sphinx version
5.0.2
Sphinx extensions
sphinx.ext.autodoc
Extra tools
No response
Additional context
This issue is probably related to #8219 and #8142.
The text was updated successfully, but these errors were encountered: