-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: validate_docstrings cleans up leftover files; doctest +SKIP file examples #44711
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
Conversation
for test in finder.find(self.raw_doc, self.name, globs=context): | ||
f = io.StringIO() | ||
runner.run(test, out=f.write) | ||
error_msgs += f.getvalue() | ||
leftovers = set(os.listdir()).difference(current_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you do this why do we need skips?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to validate that no doctest ever creates leftover files. So the workflow is
- Check if a docstring leftover a file/folder
- If so, clean up those leftover files
- Short-circut the validation and raise that a docstring leftover a file/folder
May helps potentially avoid any ResourceWarnings or potential segfaults from the docstring validation due to created files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure i get it, but you added skips to all of the doc-strings hence they are not running?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
IMO those docstrings that show an example with interacting with files should be skipped since they are more of a demonstration. The same behavior interacting with our file should be sufficient tested in the test suite.
Also I think it's better than having os.remove
everywhere in the docstrings.
And we have this precedent in the docstrings already to skip the ones that interact with files:
pandas/pandas/io/excel/_base.py
Line 292 in e992969
>>> pd.read_excel('tmp.xlsx', index_col=0) # doctest: +SKIP |
May help towards: #44590