Describe the bug
When autodoc_typehints="description", type hint comments for classes aren't fully resolved, even with autoclass_content="both".
To Reproduce
Create module.py with these contents:
from typing import Optional
Maybe = Optional
class MaybeInt(object):
""":param value: The value to hold"""
def __init__(self, value):
# type: (Maybe[int]) -> None
self.value = value
def get_value(self):
# type: () -> Maybe[int]
""":return: The held value"""
return self.value
Create index.rst with these contents:
.. automodule:: module
:members:
Generate docs twice in plain text format twice, once with autodoc_typehints="description" and once with autodoc_typehints="signature".
class module.MaybeInt(value)
Parameters:
**value** (*Maybe**[**int**]*) -- The value to hold
Return type:
None
get_value()
Returns:
The held value
Return type:
Optional[int]
In the case of the return type from get_value, the Maybe was resolved by typing.get_type_hints to be Optional. In the case of the parameter to the constructor, the Maybe was not able to be resolved.
When autodoc_typehints="signature", both were successfully resolved to Optional.
And, changing record_typehints to store the annotations of Person.__init__ for Person seems to work around the problem, though I'm not sure that's the right fix.
Describe the bug When
autodoc_typehints="description"
, type hint comments for classes aren't fully resolved, even withautoclass_content="both"
.To Reproduce Create
module.py
with these contents:Create
index.rst
with these contents:Generate docs twice in plain text format twice, once with
autodoc_typehints="description"
and once withautodoc_typehints="signature"
.And note that
signature/index.txt
has:In the case of the return type from
get_value
, theMaybe
was resolved bytyping.get_type_hints
to beOptional
. In the case of the parameter to the constructor, theMaybe
was not able to be resolved.When
autodoc_typehints="signature"
, both were successfully resolved toOptional
.Expected behavior
Type hints should be fully resolved.
Environment info
Additional context