Skip to content

Commit b09c322

Browse files
committed
update validate_docstrings.py: Returns section validation
* removed value name from error messages * updated the associated test case
1 parent 0d34a88 commit b09c322

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

scripts/tests/test_validate_docstrings.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def no_capitalization(self):
563563
Returns
564564
-------
565565
foo : str
566-
the first returned string.
566+
The first returned string.
567567
bar : str
568568
the second returned string.
569569
"""
@@ -728,10 +728,7 @@ def test_bad_generic_functions(self, func):
728728
('The first line of the Returns section should contain only the '
729729
'type, unless multiple values are being returned.',)),
730730
('BadReturns', 'no_capitalization',
731-
('Return value "foo" description should start with a capital '
732-
'letter',)),
733-
('BadReturns', 'no_capitalization',
734-
('Return value "bar" description should start with a capital '
731+
('Return value description should start with a capital '
735732
'letter',)),
736733
# See Also tests
737734
('BadSeeAlso', 'prefix_pandas',

scripts/validate_docstrings.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -500,21 +500,20 @@ def validate_one(func_name):
500500
returns_errs.append('The first line of the Returns section '
501501
'should contain only the type, unless '
502502
'multiple values are being returned.')
503+
missing_desc, missing_cap, missing_period = False, False, False
503504
for name, type_, desc in doc.returns:
504505
desc = ''.join(desc)
505-
name = '"' + name + '" ' if type_ else ''
506-
if not desc:
507-
returns_errs.append('Return value {}has no '
508-
'description'.format(name))
509-
else:
510-
if not desc[0].isupper():
511-
returns_errs.append('Return value {}description '
512-
'should start with a capital '
513-
'letter'.format(name))
514-
if desc[-1] != '.':
515-
returns_errs.append('Return value {}description '
516-
'should finish with '
517-
'"."'.format(name))
506+
missing_desc = missing_desc or not desc
507+
missing_cap = missing_cap or desc and not desc[0].isupper()
508+
missing_period = missing_period or desc and not desc.endswith('.')
509+
if missing_desc:
510+
returns_errs.append('Return value has no description.')
511+
if missing_cap:
512+
returns_errs.append('Return value description should start '
513+
'with a capital letter.')
514+
if missing_period:
515+
returns_errs.append('Return value description should finish '
516+
'with ".".')
518517
if returns_errs:
519518
errs.append('Errors in Returns section')
520519
for returns_err in returns_errs:

0 commit comments

Comments
 (0)