Skip to content

Commit 835ea1e

Browse files
douglatornellPingviinituutti
authored andcommitted
DOC: Improve GL03 message re: blank lines at end of docstrings. (pandas-dev#23649)
1 parent d29bac0 commit 835ea1e

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

scripts/tests/test_validate_docstrings.py

+39-2
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,34 @@ def astype3(self, dtype):
288288
"""
289289
pass
290290

291+
def two_linebreaks_between_sections(self, foo):
292+
"""
293+
Test linebreaks message GL03.
294+
295+
Note 2 blank lines before parameters section.
296+
297+
298+
Parameters
299+
----------
300+
foo : str
301+
Description of foo parameter.
302+
"""
303+
pass
304+
305+
def linebreak_at_end_of_docstring(self, foo):
306+
"""
307+
Test linebreaks message GL03.
308+
309+
Note extra blank line at end of docstring.
310+
311+
Parameters
312+
----------
313+
foo : str
314+
Description of foo parameter.
315+
316+
"""
317+
pass
318+
291319
def plot(self, kind, **kwargs):
292320
"""
293321
Generate a plot.
@@ -723,7 +751,8 @@ def test_bad_class(self):
723751
@capture_stderr
724752
@pytest.mark.parametrize("func", [
725753
'func', 'astype', 'astype1', 'astype2', 'astype3', 'plot', 'method',
726-
'private_classes'])
754+
'private_classes',
755+
])
727756
def test_bad_generic_functions(self, func):
728757
errors = validate_one(self._import_path( # noqa:F821
729758
klass='BadGenericDocStrings', func=func))['errors']
@@ -811,8 +840,16 @@ def test_bad_generic_functions(self, func):
811840
'E226 missing whitespace around arithmetic operator',)),
812841
('BadExamples', 'missing_whitespace_after_comma',
813842
("flake8 error: E231 missing whitespace after ',' (3 times)",)),
843+
('BadGenericDocStrings', 'two_linebreaks_between_sections',
844+
('Double line break found; please use only one blank line to '
845+
'separate sections or paragraphs, and do not leave blank lines '
846+
'at the end of docstrings',)),
847+
('BadGenericDocStrings', 'linebreak_at_end_of_docstring',
848+
('Double line break found; please use only one blank line to '
849+
'separate sections or paragraphs, and do not leave blank lines '
850+
'at the end of docstrings',)),
814851
])
815-
def test_bad_examples(self, capsys, klass, func, msgs):
852+
def test_bad_docstrings(self, capsys, klass, func, msgs):
816853
result = validate_one(self._import_path(klass=klass, func=func))
817854
for msg in msgs:
818855
assert msg in ' '.join(err[1] for err in result['errors'])

scripts/validate_docstrings.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@
6767
'in the docstring (do not close the quotes in the same line as '
6868
'the text, or leave a blank line between the last text and the '
6969
'quotes)',
70-
'GL03': 'Use only one blank line to separate sections or paragraphs',
70+
'GL03': 'Double line break found; please use only one blank line to '
71+
'separate sections or paragraphs, and do not leave blank lines '
72+
'at the end of docstrings',
7173
'GL04': 'Private classes ({mentioned_private_classes}) should not be '
7274
'mentioned in public docstrings',
7375
'GL05': 'Tabs found at the start of line "{line_with_tabs}", please use '

0 commit comments

Comments
 (0)