How do I document a type alias defined using `type` in Python?

254 Views Asked by At

Python 3.12 has the type statement. How do I document the type alias properly?

I tried:

type Number = int | float
"""Represents a scalar number that is either an integer or float"""

But this doesn't seem to associate the docstring with the alias. I tried putting the docstring after the = and before the alias definition, but that generated an error.

0

There are 0 best solutions below