Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Multiple returns #175

Open
kmvanh opened this issue Sep 16, 2021 · 1 comment
Open

Multiple returns #175

kmvanh opened this issue Sep 16, 2021 · 1 comment

Comments

@kmvanh
Copy link

kmvanh commented Sep 16, 2021

When a function features multiple Returns/Yields they cannot be individually mentioned in the docstring like Parameters would (see code example below).

def multiple_returns(a, b):
  """Multiple returns example.

  Parameters
  ----------
  a : int
      First integer
  b : int
      Second integer

  Returns
  -------
  diff : int
      b subtracted from a
  summation : int
      b added to a
  """
  diff = a - b
  summation = a + b
  return diff, summation

Instead darglint raises an error DAR000: Unexpected exception in darglint: Multiple types should be combined into a Union. The error message indicates that the Returns docstring should be structured something like:

  Returns
  -------
  Union[int, int]
    Tuple containing:
      diff : int
          b subtracted from a
      summation : int
          b added to a
  """

I don't think this is the neatest solution. Eventhough the return is a tuple, I would expect to be able to write a docstring for each individual returned variable. Can this functionality, like in the first example, be added (as an option) to darglint?

@terrencepreilly
Copy link
Owner

Sure, since it's part of the Numpy docstring spec. I haven't had time to update the numpy parser, but you're welcome to issue a pull request and I'll review it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants