Skip to content

Additional support for numpy returns section with no annotation, or just type annotation #173

@machow

Description

@machow

Describe the bug

For a numpy returns section, it seems like there may be some small issues with two cases:

  • when there is no name or type annotation specified (the annotation becomes ":")
  • when there is only an annotation (the annotation starts with ": ")

Here's a docstring with comments trying to explain the two cases:

        Returns
        -------
        list of int
            A list of integers.
        flag : bool
            Some kind
            of flag.
        x :
            Name only

        # new case ----
        # worked in a previous version of griffe. For functions with a single returns, this is
        # useful for having the return value be the functions return type hint
        :
            No name or annotation

        # new case ----
        # it looked like this may have included ": " in the annotation
        : int
            Only annotation

I can start a PR in a second, and definitely am happy to make any tweaks / changes! I realize the spec for the Returns section is a bit ambiguous, but the "no name or annotation" case seems particularly useful for just documenting the return type hint (maybe an issue similar in spirit to this one!: #137)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions