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

Py docstring type annotation #343

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

WJCFerguson
Copy link

@WJCFerguson WJCFerguson commented Sep 20, 2019

A few tweaks to the Python snippet fn for handling of args to generating docstrings, e.g. the function_docstring (key fd) snippet.

Before this it was upset by newlines in arg lists, e.g.

def foo(
        arg1,
        arg2,
):

And in addition, it didn't know what to do with type annotations, e.g:

def foo(
        arg1: int,
        arg2: str = 'default string',
):

It now excludes the type annotation from the docstring.

(I could see an argument for removing the default handling - my personal preference is to avoid duplicating the information - I'd be happy to modify the PR to do that, but who knows which users use and like this.)

So the type annotation is left out of the args list that's then used to
generate the docstring.

e.g. argument lists like:

    def fn(first_arg: str, second_arg: int = 1):
        '''

        Args:
            first_arg :
            second_arg: (default 1)
        '''
@AndreaCrotti
Copy link
Owner

Thanks, I'll test it soon but otherwise looks good to me

@AndreaCrotti AndreaCrotti added the seen PR was seen and initial feedback was given label Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
seen PR was seen and initial feedback was given
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants