Skip to content

Commit 8831109

Browse files
committed
PyCQA#129 - WIPlash
1 parent 5c4b1ed commit 8831109

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/pydocstyle/checker.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,19 +456,24 @@ def _check_section(cls, line_index, dashes_indices, lines):
456456
# meaning that the words appear there but not properly capitalized.
457457
yield violations.D405(actual_section, section)
458458

459-
if line.strip().endswith(":"):
460-
# The section name should not end with a colon.
461-
yield violations.D406(actual_section, line)
459+
suffix = line.lstrip(section).strip()
460+
if suffix:
461+
# The section name should end with a newline.
462+
yield violations.D406(actual_section, suffix)
462463

463464
next_line_index = line_index + 1
464465
if next_line_index not in dashes_indices:
465466
yield violations.D407(actual_section)
466467
else:
468+
next_line_index += 1
467469
if lines[next_line_index].strip() != "-" * len(section):
468470
# The length of the underlining dashes does not
469471
# match the length of the section name.
470472
yield violations.D408(section, len(section))
471473

474+
if lines[next_line_index].strip():
475+
yield violations.D409(actual_section)
476+
472477
@check_for(Definition)
473478
def check_docstring_internal_structure(self, definition, docstring):
474479
"""Parse the general structure of a numpy docstring and check it."""

src/pydocstyle/violations.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,13 @@ def to_rst(cls):
210210
'be `This`')
211211
D405 = D4xx.create_error('D405', 'Section name should be properly capitalized',
212212
'{0!r}, not {1!r}')
213-
D406 = D4xx.create_error('D406', 'Section name should not end with a colon',
214-
'{0!r}, not {1!r}')
213+
D406 = D4xx.create_error('D406', 'Section name should end with a newline',
214+
'{0!r}, found {1!r}')
215215
D407 = D4xx.create_error('D407', 'Missing dashed underline after section name',
216216
'section={0!r}')
217217
D408 = D4xx.create_error('D408', 'Section underline should match the length '
218218
'of the section\'s name', 'len({0!r}) == {1!r}')
219+
D409 = D4xx.create_error('D409', 'Missing blank line after section', '{0!r}')
219220

220221

221222
class AttrDict(dict):

0 commit comments

Comments
 (0)