Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validator enforces rule RT03 for return None #602

Open
gboeing opened this issue Jan 24, 2025 · 2 comments
Open

validator enforces rule RT03 for return None #602

gboeing opened this issue Jan 24, 2025 · 2 comments

Comments

@gboeing
Copy link

gboeing commented Jan 24, 2025

If I have a function like:

def return_none(number: int) -> None:
    """
    Return None.

    Parameters
    ----------
    number
        This is an argument.

    Returns
    -------
    None
    """
    number += 1
    return None

numpydoc validation fails with the error:

+-----------------+------------------+---------+---------------------------------+
| file            | item             | check   | description                     |
+=================+==================+=========+=================================+
| test.py:1       | test.return_none | RT03    | Return value has no description |
+-----------------+------------------+---------+---------------------------------+

Does the numpydoc spec actually expect return None to have a value description in the docstring? I can't find any examples of this or what the description is supposed to be. All the examples I see show no docstring description for None in this circumstance.

What should this description look like? Or is the validator in the wrong?

@stefanv
Copy link
Contributor

stefanv commented Jan 25, 2025

I think the expectation is not to have a Returns section in this case, since your function isn't returning anything.

@gboeing
Copy link
Author

gboeing commented Jan 25, 2025

That makes sense. Is that the official spec? I didn't see that that was the convention from reading through the style guide.

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

No branches or pull requests

2 participants