-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: unpin numpydoc, fix validation script #39688 #41456
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
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0a18b87
DOC: unpin numpydoc, fix validation script #39688
fangchenli ff70167
clean
fangchenli 475fac0
Merge remote-tracking branch 'upstream/master' into unpin-numpydoc
fangchenli 161d688
Merge remote-tracking branch 'upstream/master' into unpin-numpydoc
fangchenli 0f516a6
fix script
fangchenli 4b48cb3
fix tests
fangchenli e4397cf
Merge remote-tracking branch 'upstream/master' into unpin-numpydoc
fangchenli 92658e6
Merge remote-tracking branch 'upstream/master' into unpin-numpydoc
fangchenli 06cbb77
Merge remote-tracking branch 'upstream/master' into unpin-numpydoc
fangchenli b95a29f
Merge remote-tracking branch 'upstream/master' into unpin-numpydoc
fangchenli c6b7879
Merge remote-tracking branch 'upstream/master' into unpin-numpydoc
fangchenli c95fa91
Merge remote-tracking branch 'upstream/master' into unpin-numpydoc
fangchenli 9a75cef
Merge remote-tracking branch 'upstream/master' into unpin-numpydoc
fangchenli 0677c53
Merge branch 'master' into unpin-numpydoc
fangchenli 2efd84a
fix import
fangchenli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,9 @@ | |
import matplotlib | ||
import matplotlib.pyplot as plt | ||
import numpy | ||
from numpydoc.docscrape import get_doc_object | ||
from numpydoc.validate import ( | ||
Docstring, | ||
Validator, | ||
validate, | ||
) | ||
|
||
|
@@ -38,7 +39,6 @@ | |
# With template backend, matplotlib plots nothing | ||
matplotlib.use("template") | ||
|
||
|
||
PRIVATE_CLASSES = ["NDFrame", "IndexOpsMixin"] | ||
ERROR_MSGS = { | ||
"GL04": "Private classes ({mentioned_private_classes}) should not be " | ||
|
@@ -133,7 +133,7 @@ def get_api_items(api_doc_fd): | |
previous_line = line | ||
|
||
|
||
class PandasDocstring(Docstring): | ||
class PandasDocstring(Validator): | ||
@property | ||
def mentioned_private_classes(self): | ||
return [klass for klass in PRIVATE_CLASSES if klass in self.raw_doc] | ||
|
@@ -145,10 +145,17 @@ def examples_errors(self): | |
runner = doctest.DocTestRunner(optionflags=flags) | ||
context = {"np": numpy, "pd": pandas} | ||
error_msgs = "" | ||
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() | ||
name = None | ||
try: | ||
name = self.name | ||
except AttributeError: | ||
if not isinstance(self.obj, property): | ||
name = type(self.obj).__name__ | ||
if name is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. likewise, none of the tests cover when |
||
for test in finder.find(self.raw_doc, name, globs=context): | ||
f = io.StringIO() | ||
runner.run(test, out=f.write) | ||
error_msgs += f.getvalue() | ||
return error_msgs | ||
|
||
@property | ||
|
@@ -204,7 +211,8 @@ def pandas_validate(func_name: str): | |
dict | ||
Information about the docstring and the errors found. | ||
""" | ||
doc = PandasDocstring(func_name) | ||
func_obj = get_doc_object(Validator._load_obj(func_name)) | ||
doc = PandasDocstring(func_obj) | ||
result = validate(func_name) | ||
|
||
mentioned_errs = doc.mentioned_private_classes | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 isn't covered by any of the tests in
scripts/validate_docstrings.py
- when could it happen?