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
autodoc_type_aliases does not support dotted name #8588
Labels
Milestone
Comments
quick hacking... >>> class ModuleProxy:
... def __init__(self, module_name, mapper):
... self._mod = __import__(module_name)
... self._map = mapper
... def __getattr__(self, key):
... if key in self._map:
... return self._map[key]
... return getattr(self._mod, key)
...
>>> autodoc_type_aliases = {
... 'struct': ModuleProxy('struct', {'Struct': 'struct.Struct'}),
... }
>>>
>>> from __future__ import annotations # important!
>>> import struct
>>>
>>> def consume_struct(_: struct.Struct) -> struct.error:
... pass
...
>>> typing.get_type_hints(consume_struct, localns=magical)
{'_': ForwardRef('struct.Struct'), 'return': <class 'struct.error'>} ... this can be applied if Sphinx knows that |
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
May 2, 2021
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
May 3, 2021
…name It allows users to define an alias for a class with module name like `foo.bar.BazClass`.
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
May 3, 2021
…name It allows users to define an alias for a class with module name like `foo.bar.BazClass`.
tk0miya
added a commit
that referenced
this issue
May 3, 2021
Fix #8588: autodoc_type_aliases does not support dotted name
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
autodoc_type_aliases does not support dotted name
To Reproduce
The autodoc_type_aliases entry does not work as expected.
(refs: #8315)
Expected behavior
Supporting
Your project
No
Screenshots
No
Environment info
Additional context
No
The text was updated successfully, but these errors were encountered: