Search code examples
pythonrestructuredtextdocstring

How to specify return type and describe the return value in one-line ReST docstring?


I know I can abbreviate the following ReST docstring

"""
:type flag: bool
:param flag: new value for the flag
"""

as

"""
:param bool flag: new value for the flag
"""

Can I abbreviate in a similar manner the following?

"""
:rtype: bool
:returns: new value of flag
"""

Solution

  • It is not possible. The description must be specified in returns or return and the return type in a rtype. Merging these into one line is not allowed.