Open robsdedude opened 10 months ago
__init__
and possibly __new__
, right?t
in the local namespaces, leading to this bug.I know where to look roughly but since I cannot do anything (or not much) with only my phone+termux, I will only be able to look at it in mid October.
In the meantime, you could try to specify a type alias using autodoc_type_aliases
(check the doc for that). As I said in https://github.com/sphinx-doc/sphinx/issues/11652#issuecomment-1707736322, we can improve the type aliases map to handle those cases. Upon my return, I will draft an improvement of the latter in order to fix autodoc a bit more.
Thanks for hinting me at autodoc_type_aliases
. I shall have a look and see if it allows me to work around the problem.
Describe the bug
Turning https://github.com/sphinx-doc/sphinx/issues/10605#issuecomment-1199462450 into its own issue.
With
autodoc_typehints = 'description'
in the sphinx config andfrom __future__ import annotations
in the Pythonfile, the parameter type annotations of the constructor (__init__
) are not resolved correctly.How to Reproduce
mylib.__init__.py
index.rst
Sphinx
conf.py
This results in![image](https://github.com/sphinx-doc/sphinx/assets/4061254/ab1609ad-aecd-4a80-a61b-28155e3e0d3a)
Removing![image](https://github.com/sphinx-doc/sphinx/assets/4061254/882eaafe-124e-4993-b36a-22ebd9ff8983)
from __future__ import annotations
frommylib.__init__.py
makes the problem go awayLike wise does (only) removing![image](https://github.com/sphinx-doc/sphinx/assets/4061254/4de76743-d075-4cab-a85c-40e2c58f8862)
autodoc_typehints = "description"
fromconf.py
resolve the issue (even though it makes the type info appear in a different place as intended)Environment Information
Sphinx extensions