How to express multiple types for a single parameter or a return value in docstrings that are processed by Sphinx?

Python 3.10 | (pipe, binary or) Union type hint syntax sugar Once you get access, this will be the way to go, it is sweet: def f(i: int|str) -> int|str: if type(i) is str: return int(i) + 1 else: return str(i) The PEP: https://peps.python.org/pep-0604/ Documented at: https://docs.python.org/3.11/library/typing.html#typing.Union Union type; Union[X, Y] is equivalent to X … Read more