Docstrings in Pycharm | Sololearn: Learn to code for FREE!

0

Docstrings in Pycharm

Why, in Pycharm, when I want to make a docstring, pycharm thinks it is a standard string? I understood this by the color (the docstring should be gray, but it is displayed in yellow, and Pycharm also suggests converting triple quotes to single quotes and enclosing it all in brackets).

7/24/2020 9:30:21 AM

Granger

7 Answers

New Answer

+4

Some other things you can try or check: Go to a method or function that doesn't have a Docstring (or remove it), select the method/function name so it is highlighted. When the code assistant light bulb shows, click the down arrow and select "Specify return type in docsrting". This should write a Docstring into your function/method in the chosen settings format. Then you should be able to add whatever else you need to the docstring. It should work similarly for classes etc. You can also check in the settings; Settings > Tools > Python Integrated Tool > Docstrings > Docstring format:, Check Analyze Python code in docstrings

+3

You can verify you're seeing the correct color or change them by going to Settings > Editor > Color Scheme > Python > Docstring > Tag/Text Also check the Docstring example there and make sure you are following PEP standards so they will show correctly. Be sure to use triple double quotes and not singles. https://www.python.org/dev/peps/pep-0257/

+3

You can also try going to the top of the file or some other normal place where a Docstring would be expected and type in 3 single quotes and press enter. Pycharm linting should recognize this as an incorrect Docstring and place the squiggly lines under the quotes. Select the quotes so that the code assistant light bulb shows, click the down arrow and choose the option to change to double quotes. This will give you a Docstring according to your settings.

+2

No, that is the default. Mine is the same. https://www.jetbrains.com/help/pycharm/settings-tools-python-integrated-tools.html

0

As for the color, everything is for sure. As for PEP8, I turned it off, I know and stick to it, but I am not going to do the inconvenient moments for me in the way that is inconvenient for me. As for the quotes - even if they are single, even if they are double, it makes no difference.

0

I can make exactly the docstring only at the beginning of the file, elsewhere it is the line

0

ChaoticDawg, docstring format: reStructuredText. Should I change this? As for the analysis, it is included