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

Commit af164f6

Browse files
author
Vladimir Keleshev
committed
Merge pull request #64 from ziadsawalha/remove-D209
Update D209 to reflect change to PEP-257
2 parents 7b46984 + d72b205 commit af164f6

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
@@ -599,22 +599,21 @@ def check_indent(self, definition, docstring):
599599
return Error('D207: Docstring is under-indented')
600600

601601
@check_for(Definition)
602-
def check_blank_after_last_paragraph(self, definition, docstring):
603-
"""D209: Multi-line docstring should end with 1 blank line.
602+
def check_newline_after_last_paragraph(self, definition, docstring):
603+
"""D209: Put multi-line docstring closing quotes on separate line.
604604
605-
The BDFL recommends inserting a blank line between the last
606-
paragraph in a multi-line docstring and its closing quotes,
607-
placing the closing quotes on a line by themselves.
605+
Unless the entire docstring fits on a line, place the closing
606+
quotes on a line by themselves.
608607
609608
"""
610609
if docstring:
611610
lines = [l for l in eval(docstring).split('\n') if not is_blank(l)]
612611
if len(lines) > 1:
613612
lines = eval(docstring).split('\n')
614613
blanks = len(list(takewhile(is_blank, reversed(lines))))
615-
if blanks != 2:
616-
return Error('D209: Multi-line docstring should end with '
617-
'1 blank line, found %s' % max(0, blanks - 1))
614+
if blanks < 2:
615+
return Error('D209: Put multi-line docstring closing '
616+
'quotes on separate line')
618617

619618
@check_for(Definition)
620619
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)