on-internet
← Community

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

Stack Overflow ·

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.

Comments

Sign in or sign up to comment and upvote.

No comments yet.