Skip to content

Support type annotations in Returns and Yields sections #356

Open
@marvinpfoertner

Description

@marvinpfoertner

Currently, when using numpydoc-style docstrings alongside Python type annotation, the types of returns or yields must be specified twice, which is tedious and also error prone. I would like to propose a backward-compatible addition to the docstring specification, which allows returns/yields to be specified without return types:

Returns
-------
return1_name :
    Description of `return1_name`.
return2_name :
    Description of `return2_name`.

Note the addition of the colons to distinguish return names and return types in a backward-compatible way.
Additionally, for a single return value with a Python return type annotation, it would be great if the following would be possible:

Returns
-------
Description of the return

or

Returns
-------
    Description of the return

The same suggestions should also work for the Yields section

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions