Skip to content

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

Open

Description

@gcaria

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?

Activity

  1. pixelneo commented on Apr 1, 2022

    @pixelneo
    Owner

    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.

  2. gcaria commented on Apr 1, 2022

    @gcaria
    Author

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions