Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test in scripts/validate_docstrings.py that the short summary is always one line long #22617

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions scripts/tests/test_validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ def multi_line(self):
which is not correct.
"""

def two_paragraph_multi_line(self):
"""
Extends beyond one line
which is not correct.

Extends beyond one line, which in itself is correct but the
previous short summary should still be an issue.
"""


class BadParameters(object):
"""
Expand Down Expand Up @@ -557,6 +566,8 @@ def test_bad_generic_functions(self, func):
('Summary must start with infinitive verb',)),
('BadSummaries', 'multi_line',
('a short summary in a single line should be present',)),
('BadSummaries', 'two_paragraph_multi_line',
('a short summary in a single line should be present',)),
# Parameters tests
('BadParameters', 'missing_params',
('Parameters {**kwargs} not documented',)),
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def double_blank_lines(self):

@property
def summary(self):
if not self.doc['Extended Summary'] and len(self.doc['Summary']) > 1:
if len(self.doc['Summary']) > 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm what's the point of this condition at all? Haven't stepped through in detail but seems like it might just be an erroneous copy / paste from extended_summary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My feeling is also that it was an erroneous copy from extended_summary. The current check returns an error only when the summary is empty hence my change here.

I could probably simply return self.doc['Summary'] for this method and add another @property to obtain the number of lines of the summary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just return the summary here and update the check to detect multiple lines? Don't want to get too far off topic here but raising an error on an empty string seems rather arbitrary

return ''
return ' '.join(self.doc['Summary'])

Expand Down