Reputation: 1049
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
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
Reputation: 3294
Make sure a docstring format is selected in File → Settings → Tools → Python Integrated Tools
Upvotes: 29
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:
Upvotes: 20
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