Given the following function in a module called mymodule that I want to document using Sphinx with autodoc:
from typing import Union
from collections.abc import Iterable
from numpy.typing import ArrayLike
def foo(a: Union[str, int], b: Iterable, c: ArrayLike) -> None:
"""Do something useful."""
pass
In the source, the function's signature is quite readable. However, in the documentation generated by autodoc the signature is displayed as
khadl._util.foo(a: Union[str, int], b: collections.abc.Iterable, c: Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray]) → None
which is just unreadable. The classes stemming from the typing module are displayed in a short form (Union, Sequence, Any), but for the abstract base class Iterable a unique identifier is generated (collections.abc.Iterable) and ArrayLike is even "unpacked" (Union[int, float, complex, str, bytes, numpy.generic, Sequence[Union[int, float, complex, str, bytes, numpy.generic]], Sequence[Sequence[Any]], numpy.typing._array_like._SupportsArray]).
How can I configure Sphinx so that the function's signature is displayed in a readable way in the documentation, e.g. as in the source code?