eriophora
eriophora

Reputation: 1049

Pycharm does not auto-create documentation stubs

I'm not sure why this is happening on this computer; it's never happened on any other. When I try to create a docstring for a function or class in pycharm, nothing happens. I.e.:

def foo(bar):
    """"""
    pass

Should insert a docstring upon pressing enter; instead it simply does:

def foo(bar):
    """
    """
    pass

Upvotes: 21

Views: 13197

Answers (5)

asymmetryFan
asymmetryFan

Reputation: 732

In order to solve this problem, I had to go into Settings → Tools → Python Integrated Tools and reset the docstring format. I did so by changing Docstring format from Epytext to Plain, clicking Apply, then changing it back to Epytext again and applying the change, and now everything works.

PyCharm version: 2021.1.2 (Community Edition)

Upvotes: 19

geometrikal
geometrikal

Reputation: 3294

Make sure a docstring format is selected in File → Settings → Tools → Python Integrated Tools

Upvotes: 29

FLBKernel
FLBKernel

Reputation: 860

I was having this same problem for pyCharm 2019.3.1 and I just solved it following this instructions at the pyCharm site's documentation

Specifically at the "Docstring format" section, following this:

Docstring format

Upvotes: 20

Michael Anslow
Michael Anslow

Reputation: 397

I managed to fix this by changing my keyboard preferences on MacOSX from U.S. International - PC to British. The double quotation mark in U.S. International - PC triggers the system to wait for a letter to accent e.g " then e becomes ë. However, it doesn't seem to behave the same way in all editors.

Mere speculation, but perhaps there is some formatting magic going on in the background in PyCharm which is not working properly because of some additional (also unseen) formatting added when using U.S. International - PC that prevents PyCharm from adding the context it needs to know it should created the docstring after pressing enter?

Upvotes: 0

arewm
arewm

Reputation: 649

This is a known bug and should be fixed in 2016.1.1.

One workaround, as described in the issue:

A workaround for this is to just """ before the code of your first line, then drop that code down a newline when it populates. Clunky, but it is a workaround for now.

Upvotes: 4

Related Questions