When quickly checking why one thing or another is breaking on a remote machine, I often end up in a repl where I use help() to look at whatever seems to cause an issue. Naturally, a common problem that the wrong thing gets passed into another thing, and so it is very useful to see type annotations in help(). Unfortunately, quite often those end up being useless, because help() cannot un-resolve type aliases.
For reference, take this function definition:
>>> from numpy.typing import NDArray, ArrayLike >>> def square(x: ArrayLike) -> NDArray: ... return np.square(x)
and its help() output:
square(x: Union[numpy.__array_like._SupportsArray[numpy.dtype], numpy.__nested_sequence._NestedSequence[numpy.__array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.__nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]) -> numpy.ndarray[typing.Any, numpy.dtype[+ScalarType]]
That’s of course because
ArrayLike is a complicated beast, and what makes it into the function signature is its value, not its name.
It would therefore have been nice if PEP 613 had given us an optional construct like this:
ArrayLike = TypeAlias('ArrayLike', ...)
so that help() and such could display more meaningful type aliases.