WestCoastProjects
WestCoastProjects

Reputation: 63062

How does "Insert documentation comment stub" work in Pycharm for getting method parameters?

I have enabled Insert documentation comment stub within Editor | General |Smart keys :

smart keys settings

But then how to get the method parameters type stubs? Adding the docstring triple quotes and then enter does open up the docstring - but with nothing in it:

def get_self_join_clause(self, df, alias1='o', alias2 = 'n'):
    """
    
    """   # pycharm added this automatically

Upvotes: 1

Views: 533

Answers (1)

bad_coder
bad_coder

Reputation: 12880

how to get the method parameters type stubs?

PyCharm does generate the docstring stub with the type placeholders, but the placeholders aren't currently (using PyCharm 2022.1) populated from the __annotations__ with the types. This has been marked with the state "To be discussed" in the JetBrains bugtracker, see issues PY-23400 and PY-54930.

Inclusion of the type placeholders is configured by checking File > Settings > Editor > General > Smart Keys > Python > Insert type placeholders in the documentation comment stub.



It's worth noting the insert docstring stub intention is selected on the function name itself

function in editor with intention

In this example with Napoleon style docstring format selected in File > Settings > Tools > Python Integrated Tools > Docstrings, the result:

editor after docstring stub insertion

Upvotes: 1

Related Questions