Skip to content

Commit 6a64a62

Browse files
committed
Update error message and test validator
1 parent f85e296 commit 6a64a62

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

scripts/tests/test_validate_docstrings.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,6 @@ def method(self, foo=None, bar=None):
333333
"""
334334
pass
335335

336-
337-
class BadSeeAlso(object):
338-
339-
def prefix_pandas(self):
340-
"""
341-
Return prefix with `pandas` from See Also sec
342-
"""
343-
pass
344-
345336
class BadSummaries(object):
346337

347338
def wrong_line(self):
@@ -553,6 +544,13 @@ def no_punctuation(self):
553544
"""
554545
return "Hello world!"
555546

547+
class BadSeeAlso(object):
548+
549+
def prefix_pandas(self):
550+
"""
551+
Return prefix with `pandas` from See Also sec
552+
"""
553+
pass
556554

557555
class TestValidator(object):
558556

@@ -616,9 +614,6 @@ def test_bad_generic_functions(self, func):
616614
assert errors
617615

618616
@pytest.mark.parametrize("klass,func,msgs", [
619-
#SeeAlso tests
620-
('BadSeeAlso', 'prefix_pandas',
621-
('Should not start with pandas',)),
622617
# Summary tests
623618
('BadSummaries', 'wrong_line',
624619
('should start in the line immediately after the opening quotes',)),
@@ -667,7 +662,10 @@ def test_bad_generic_functions(self, func):
667662
pytest.param('BadReturns', 'no_description', ('foo',),
668663
marks=pytest.mark.xfail),
669664
pytest.param('BadReturns', 'no_punctuation', ('foo',),
670-
marks=pytest.mark.xfail)
665+
marks=pytest.mark.xfail),
666+
# SeeAlso tests
667+
('BadSeeAlso', 'prefix_pandas',
668+
('Should not start with pandas',)),
671669
])
672670
def test_bad_examples(self, capsys, klass, func, msgs):
673671
result = validate_one(self._import_path(klass=klass, func=func)) # noqa:F821

scripts/validate_docstrings.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,9 @@ def validate_one(func_name):
508508
if not rel_desc:
509509
errs.append('Missing description for '
510510
'See Also "{}" reference'.format(rel_name))
511-
if rel_name[:7].lower() == 'pandas.':
512-
errs.append('{} should not have prefix `pandas`'.format(rel_name))
511+
if rel_name.startswith('pandas.'):
512+
errs.append('{} in the `See Also` section does not need the `pandas` prefix, '
513+
'use {} instead.'.format(rel_name,rel_name.replace('pandas.','')))
513514
for line in doc.raw_doc.splitlines():
514515
if re.match("^ *\t", line):
515516
errs.append('Tabs found at the start of line "{}", '

0 commit comments

Comments
 (0)