4

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?

Barzi2001
  • 989
  • 8
  • 24

1 Answers1

3

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.

S.B
  • 13,077
  • 10
  • 22
  • 49
  • 1
    In this case `and this is the second line` refers to the description. in your case. I want it to be part of the summary. I edited my main post to be more clear. – Barzi2001 Sep 09 '22 at 12:45
  • @Barzi2001 see the update. – S.B Sep 09 '22 at 13:04
  • 1
    I see. That is very annoying for all those who like to use the 80 columns limit. It would be interesting to understand what prevented the detection of the border summary-description by only the first blank line. I see an unnecessary redundancy there. But that is the way it is I guess... – Barzi2001 Sep 09 '22 at 13:53
  • I also noticed that even if you keep everything in one line, you shall not use periods, but only one period is allowed and it shall be place at the end of the summary. – Barzi2001 Sep 09 '22 at 13:53