I have a function with type annotations using type aliases in Python
ExampleArrayLike = Union[list, np.ndarray]
def module_level_function_5(
array_like: ArrayLike,
array: numpy.ndarray
) -> ExampleArrayLike:
Sphinx autodoc provides functionalities to not parse the alias, but to display as is by settings in conf.py
:
autodoc_type_aliases = {
'ArrayLike': 'numpy.typing.ArrayLike',
'ExampleArrayLike': 'ExampleArrayLike',
}
My issue now is, that intersphinx does not provide hyperlinks to the documentation of the objects ArrayLike
and ExampleArrayLike
. The type hint for array
is a working hyperlink though and leads me to the docs of numpy, see image below.
Built docs, ndarray is linked, type aliases are not
First question: How can this be achieved?
I am also using the napoleon extension, which also provides configurations
napoleon_type_aliases = {}
But that one does not work either
Other questions: Do napoleon type aliases and autodoc aliases work the same way? And are there any known conflicts between the usage of those two?
I tried various combinations type alias mappings, including the possibilities mentioned here
Best regards,