0

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,

mzjn
  • 48,958
  • 13
  • 128
  • 248
hajdukv
  • 1
  • 2
  • It seems like this is still an open issue on Sphinx' side https://github.com/sphinx-doc/sphinx/issues/10785 – hajdukv Nov 24 '22 at 16:29

0 Answers0