Ashley Alfredssons
Ashley Alfredssons

Reputation: 109

python automatically adding type hints in docstring

I'm looking for a tool that adds the type annotation that are already added in a function to the docstring generated by PyCharm.

I have been following this issue on JetBrains for a long time and no progress seem to be made on this ticket yet.

I saw this article as well but it seems too specific and only works with google docstrings.

I have checked out this package on PyPI but this does the opposite of what I need. What I need is to add the type hints provided in the argument to the docstring and not the opposite.

This might be related to How to make PyCharm get type hints from function definition and populate type values in docstrings?, but I just need a general purpose solution, or at least one that works with Numpy docstring or reStructuredText and maybe play nicely with PyCharm.

I just see myself coming back to researching this thing in the hopes of getting something but couldn't find what I needed. What tools would work for this?

Upvotes: 5

Views: 2899

Answers (1)

zweack
zweack

Reputation: 131

When I was searching few months ago, I couldn't find any usable solution for this. Right now, I am using VS Code with this extension which gives nice Docstring:

def foo(a: int, b: str) -> bool:
    """[summary]

    Args:
        a (int): [description]
        b (str): [description]

    Returns:
        bool: [description]
    """

Upvotes: 4

Related Questions