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

Bug: Requires Return Section in Docstring When None Is the Return Type #6

Closed
rbebb opened this issue May 23, 2023 · 4 comments · Fixed by #10
Closed

Bug: Requires Return Section in Docstring When None Is the Return Type #6

rbebb opened this issue May 23, 2023 · 4 comments · Fixed by #10
Assignees

Comments

@rbebb
Copy link

rbebb commented May 23, 2023

I noticed that docstrings require a return section even when the return type is None, but this only occurs when there are parameters in the function. The error does not occur if there are zero parameters in the function. Also, the docstrings use Google style.

Example (Error):

def test(text: str) -> None:
    """Run test.

    Args:
        text (str): Text for the function
    """

Example (Pass):

def test() -> None:
    """Run test.

    """
@jsh9
Copy link
Owner

jsh9 commented May 24, 2023

Hi @rbebb ,

Thank you for reporting this issue.

docstrings require a return section even when the return type is None

I implemented this check because this seems to be the convention of the numpy-style docstring:

"""
Parameters
-----------
arg1 : int
    Something
arg2 : str
    Something else

Returns
--------
None
"""

I can add a configurable option that allows us to not add a "returns" section when the function returns None (implicitly or explicitly).

but this only occurs when there are parameters in the function

Yep, this is an intended behavior.

By pydoclint's default, the option --skip-checking-short-docstrings is set to True. Short docstrings (not an "official" term though) are those only with a description but no "args" or "returns" sections.

This allows us to be a bit "lazy" for some self-explanatory functions/methods.

But as soon as we add an "args" section in our docstring, it is no longer a "short docstring", which is why pydoclint starts to check the existence of a "Returns" section.

@jsh9
Copy link
Owner

jsh9 commented May 31, 2023

Hi @rbebb , I've fixed this issue in a PR. This fix will be shipped with the newest release in a day or two.

@jsh9
Copy link
Owner

jsh9 commented May 31, 2023

Hi @rbebb , I just published version 0.0.5, which includes this fix.

@rbebb
Copy link
Author

rbebb commented May 31, 2023

Thank you very much! I appreciate you making that change!

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

Successfully merging a pull request may close this issue.

2 participants