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

Conversation

Moisan
Copy link
Contributor

@Moisan Moisan commented Sep 6, 2018

The previous test to check if the summary property should be empty was based on the non-existence of the extended summary which doesn't seem to make sense. The test case I added failed before changing the script.

@pep8speaks
Copy link

Hello @Moisan! Thanks for submitting the PR.

@@ -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

@WillAyd WillAyd added Testing pandas testing functions or related to the test suite Docs labels Sep 6, 2018
@codecov
Copy link

codecov bot commented Sep 7, 2018

Codecov Report

Merging #22617 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #22617   +/-   ##
=======================================
  Coverage   92.04%   92.04%           
=======================================
  Files         169      169           
  Lines       50782    50782           
=======================================
  Hits        46744    46744           
  Misses       4038     4038
Flag Coverage Δ
#multiple 90.45% <ø> (ø) ⬆️
#single 42.26% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46abe18...8e08dd6. Read the comment docs.

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

@property
def num_summary_lines(self):
Copy link
Member

Choose a reason for hiding this comment

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

Overall approach is much cleaner here, though I'm maybe -0.5 on the property as I don't see this really being used outside of the one check you have, in which case you can probably just do len(self.doc['Summary']) directly

I'll defer to the @datapythonista on this one though

@jreback jreback added this to the 0.24.0 milestone Sep 7, 2018
@jreback
Copy link
Contributor

jreback commented Sep 18, 2018

@datapythonista pls merge if ok

@datapythonista datapythonista merged commit ace341e into pandas-dev:master Sep 18, 2018
@datapythonista
Copy link
Member

thanks @Moisan

@Moisan Moisan deleted the docstring_validate_short_summary branch September 18, 2018 13:27
aeltanawy pushed a commit to aeltanawy/pandas that referenced this pull request Sep 20, 2018
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: scripts/validate_docstrings.py should detect when the short summary span over multiple lines
5 participants