Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write docstring summary on multiple lines without triggering D205 and D400?

Say that I have

def foo()
    """This is the first part of the summary, 
    and this is the second part of the summary.

    This is the description.
    """

I got both D205 and D400 docstring style warnings triggered. I want to be able to break the line because I am working with the 80-columns limit and I want to keep it.

Shall I just ignore these warnings?

like image 813
Barzi2001 Avatar asked Oct 26 '25 21:10

Barzi2001


1 Answers

From pycodestyle documentation:

D205: 1 blank line required between summary line and description

D400: First line should end with a period

So this should be fine:

def foo():
    """This is the first line of the summary.

    and this is the second.
    This is the description.
    """

To answer you comment:

Pep-0257 says:

Multi-line docstrings consist of a summary line just like a one-line docstring, followed by a blank line, followed by a more elaborate description. The summary line may be used by automatic indexing tools; it is important that it fits on one line and is separated from the rest of the docstring by a blank line.

So you should shrink it down so that it fits in one line. That first line is used by some libraries like click. So multi line summary is not correct at the first place.

like image 68
SorousH Bakhtiary Avatar answered Oct 29 '25 12:10

SorousH Bakhtiary



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!