Skip to content

Add Returns: None when no explicit return statement is found #17

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

Open
gcaria opened this issue Apr 1, 2022 · 2 comments
Open

Add Returns: None when no explicit return statement is found #17

gcaria opened this issue Apr 1, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@gcaria
Copy link

gcaria commented Apr 1, 2022

Hi, just another small feedback on your great plugin.

I haven't found any official guideline for what to put in a docstring when no explicit return statement is found,
but this stackoverflow question suggests it should be like this:

"""Prints the element given as input

Args:
    x: any element
Returns:
    None
"""

Do you think this is something you could/would like to implement?

@pixelneo
Copy link
Owner

pixelneo commented Apr 1, 2022

Thank you for the feedback.

According to PEP 257, "The docstring for a function or method should summarize its behavior and document its arguments, return value(s), side effects, exceptions raised, and restrictions on when it can be called (all if applicable)".
Therefore, strictly speaking, I do not think it should be there,
If a function does not contain return expression it always returns None, so why write it down.

However, I am open to adding this (optional) functionality (PRs are welcome :-)).
I might implement it myself, but I can't promise when.

@pixelneo pixelneo added the enhancement New feature or request label Apr 1, 2022
@gcaria
Copy link
Author

gcaria commented Apr 1, 2022

You're right, it's debatable.

About your PEP 257 quote, one could argue that since a function always has a return value, then it's always applicable to document its return value (including None).

I'll have a look into the actual code of your plugin, not a vim code expert, but maybe it's easy ;)

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

No branches or pull requests

2 participants