Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit d72b205

Browse files
committed
Update D209
The requirement for an extra line at the end of a multi-line docstring has been updated to only require the closing quotes to be on a separate line. Ref: https://codereview.appspot.com/69870043
1 parent 012e042 commit d72b205

File tree

4 files changed

+9
-43
lines changed

4 files changed

+9
-43
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ are grouped as follows:
100100
+--------------+--------------------------------------------------------------+
101101
| D20{7,8} | Docstring {under,over}-indented. |
102102
+--------------+--------------------------------------------------------------+
103-
| D209 | Multi-line docstring should end with 1 blank line. |
103+
| D209 | Put multi-line docstring closing quotes on separate line. |
104104
+--------------+--------------------------------------------------------------+
105105
| **Quotes issues** |
106106
+--------------+--------------------------------------------------------------+

pep257.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -588,22 +588,21 @@ def check_indent(self, definition, docstring):
588588
return Error('D207: Docstring is under-indented')
589589

590590
@check_for(Definition)
591-
def check_blank_after_last_paragraph(self, definition, docstring):
592-
"""D209: Multi-line docstring should end with 1 blank line.
591+
def check_newline_after_last_paragraph(self, definition, docstring):
592+
"""D209: Put multi-line docstring closing quotes on separate line.
593593
594-
The BDFL recommends inserting a blank line between the last
595-
paragraph in a multi-line docstring and its closing quotes,
596-
placing the closing quotes on a line by themselves.
594+
Unless the entire docstring fits on a line, place the closing
595+
quotes on a line by themselves.
597596
598597
"""
599598
if docstring:
600599
lines = [l for l in eval(docstring).split('\n') if not is_blank(l)]
601600
if len(lines) > 1:
602601
lines = eval(docstring).split('\n')
603602
blanks = len(list(takewhile(is_blank, reversed(lines))))
604-
if blanks != 2:
605-
return Error('D209: Multi-line docstring should end with '
606-
'1 blank line, found %s' % max(0, blanks - 1))
603+
if blanks < 2:
604+
return Error('D209: Put multi-line docstring closing '
605+
'quotes on separate line')
607606

608607
@check_for(Definition)
609608
def check_triple_double_quotes(self, definition, docstring):

test.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -158,31 +158,13 @@ def asdfsdfsdsdsdfsdf24():
158158
"""
159159

160160

161-
@expect('D209: Multi-line docstring should end with 1 blank line, found 0')
161+
@expect('D209: Put multi-line docstring closing quotes on separate line')
162162
def asdfljdf24():
163163
"""Summary.
164164
165165
Description."""
166166

167167

168-
@expect('D209: Multi-line docstring should end with 1 blank line, found 0')
169-
def asdljlfljdf24():
170-
"""Summary.
171-
172-
Description.
173-
"""
174-
175-
176-
@expect('D209: Multi-line docstring should end with 1 blank line, found 2')
177-
def lklkjllkjl():
178-
"""Summary.
179-
180-
Description.
181-
182-
183-
"""
184-
185-
186168
@expect('D300: Expected """-quotes, got \'\'\'-quotes')
187169
def lsfklkjllkjl():
188170
r'''Summary.'''

test_pep257.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,3 @@ def test_check_indent():
222222
"""
223223
pass'''
224224
assert check('"""%s"""' % context.split('"""')[1], context, None)
225-
226-
227-
def test_check_blank_after_last_paragraph():
228-
check = pep257.check_blank_after_last_paragraph
229-
s1 = '''"""Multiline docstring should end with 1 blank line.
230-
231-
Blank here:
232-
233-
"""'''
234-
s2 = '''"""Multiline docstring should end with 1 blank line.
235-
236-
No blank here.
237-
"""'''
238-
assert not check(s1, None, None)
239-
assert check(s2, None, None)

0 commit comments

Comments
 (0)