-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Add ignore-deprecate argument to validate_docstrings.py #23650
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
Merged
jorisvandenbossche
merged 25 commits into
pandas-dev:master
from
charlesdong1991:add_ignore_deprecated
Nov 18, 2018
Merged
Changes from 23 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e1fc4d5
add ignore-deprecate argument and add pytest
charlesdong1991 a08cb6d
fix flake8
charlesdong1991 42e372f
correct argument name
charlesdong1991 e569cf2
code changed based on review
charlesdong1991 09be5aa
change name and help description
charlesdong1991 e7a723b
add ignore_deprecated description for functiondocstring
charlesdong1991 70b0fcb
debug the error
charlesdong1991 66b9de3
debug the error
charlesdong1991 f5d28fe
set default value for ignore-deprecated
charlesdong1991 49188dd
bug fixing
charlesdong1991 901b943
add positional argument for lambda
charlesdong1991 c1f44a4
remove wrong lambda
charlesdong1991 1095a9a
add argument for setattr
charlesdong1991 26e1d04
correct argument name
charlesdong1991 b199099
assign true to ignore deprecated
charlesdong1991 b384e79
debug the error
charlesdong1991 a0f9d21
correct the assert value
charlesdong1991 af35c19
modify pytest
charlesdong1991 f1a66a6
rewrite pytest
charlesdong1991 79e5706
remove added part to test if the failure caused by my code
charlesdong1991 83cc28c
put tests back
charlesdong1991 1ed082a
remove curly bracket position
charlesdong1991 14e522a
change formatting
charlesdong1991 2418c0c
remove redunctant default value
charlesdong1991 f20fee1
set default to False
charlesdong1991 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -817,6 +817,20 @@ def test_bad_examples(self, capsys, klass, func, msgs): | |
for msg in msgs: | ||
assert msg in ' '.join(err[1] for err in result['errors']) | ||
|
||
def test_validate_all_ignore_deprecated(self, monkeypatch): | ||
monkeypatch.setattr( | ||
validate_docstrings, 'validate_one', lambda func_name: { | ||
'docstring': 'docstring1', | ||
'errors': [('ER01', 'err desc'), | ||
('ER02', 'err desc'), | ||
('ER03', 'err desc')], | ||
'warnings': [], | ||
'examples_errors': '', | ||
'deprecated': True}) | ||
result = validate_docstrings.validate_all(prefix=None, | ||
ignore_deprecated=True) | ||
assert len(result) == 0 | ||
|
||
|
||
class TestApiItems(object): | ||
@property | ||
|
@@ -907,12 +921,14 @@ def test_exit_status_for_validate_one(self, monkeypatch): | |
exit_status = validate_docstrings.main(func_name='docstring1', | ||
prefix=None, | ||
errors=[], | ||
output_format='default') | ||
output_format='default', | ||
ignore_deprecated=False) | ||
assert exit_status == 0 | ||
|
||
def test_exit_status_errors_for_validate_all(self, monkeypatch): | ||
monkeypatch.setattr( | ||
validate_docstrings, 'validate_all', lambda prefix: { | ||
validate_docstrings, 'validate_all', | ||
lambda prefix, ignore_deprecated=None: { | ||
'docstring1': {'errors': [('ER01', 'err desc'), | ||
('ER02', 'err desc'), | ||
('ER03', 'err desc')], | ||
|
@@ -925,25 +941,29 @@ def test_exit_status_errors_for_validate_all(self, monkeypatch): | |
exit_status = validate_docstrings.main(func_name=None, | ||
prefix=None, | ||
errors=[], | ||
output_format='default') | ||
output_format='default', | ||
ignore_deprecated=False) | ||
assert exit_status == 5 | ||
|
||
def test_no_exit_status_noerrors_for_validate_all(self, monkeypatch): | ||
monkeypatch.setattr( | ||
validate_docstrings, 'validate_all', lambda prefix: { | ||
validate_docstrings, 'validate_all', | ||
lambda prefix, ignore_deprecated=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. same here, and in the rest of cases |
||
'docstring1': {'errors': [], | ||
'warnings': [('WN01', 'warn desc')]}, | ||
'docstring2': {'errors': []}}) | ||
exit_status = validate_docstrings.main(func_name=None, | ||
prefix=None, | ||
errors=[], | ||
output_format='default') | ||
output_format='default', | ||
ignore_deprecated=False) | ||
assert exit_status == 0 | ||
|
||
def test_exit_status_for_validate_all_json(self, monkeypatch): | ||
print('EXECUTED') | ||
monkeypatch.setattr( | ||
validate_docstrings, 'validate_all', lambda prefix: { | ||
validate_docstrings, 'validate_all', | ||
lambda prefix, ignore_deprecated=None: { | ||
'docstring1': {'errors': [('ER01', 'err desc'), | ||
('ER02', 'err desc'), | ||
('ER03', 'err desc')]}, | ||
|
@@ -952,12 +972,14 @@ def test_exit_status_for_validate_all_json(self, monkeypatch): | |
exit_status = validate_docstrings.main(func_name=None, | ||
prefix=None, | ||
errors=[], | ||
output_format='json') | ||
output_format='json', | ||
ignore_deprecated=False) | ||
assert exit_status == 0 | ||
|
||
def test_errors_param_filters_errors(self, monkeypatch): | ||
monkeypatch.setattr( | ||
validate_docstrings, 'validate_all', lambda prefix: { | ||
validate_docstrings, 'validate_all', | ||
lambda prefix, ignore_deprecated=None: { | ||
'Series.foo': {'errors': [('ER01', 'err desc'), | ||
('ER02', 'err desc'), | ||
('ER03', 'err desc')], | ||
|
@@ -973,11 +995,13 @@ def test_errors_param_filters_errors(self, monkeypatch): | |
exit_status = validate_docstrings.main(func_name=None, | ||
prefix=None, | ||
errors=['ER01'], | ||
output_format='default') | ||
output_format='default', | ||
ignore_deprecated=False) | ||
assert exit_status == 3 | ||
|
||
exit_status = validate_docstrings.main(func_name=None, | ||
prefix=None, | ||
errors=['ER03'], | ||
output_format='default') | ||
output_format='default', | ||
ignore_deprecated=False) | ||
assert exit_status == 1 |
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
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.
Sorry I didn't see that before...
ignore_deprecated
expects a boolean value, I don't think we should pass None. And I see that it has a default value ofFalse
that is what we want. So, can you restore the original code? I think it should work, right?Uh oh!
There was an error while loading. Please reload this page.
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.
ahh, i did this because i thought right now,
validate_all
takes in two arguments, and althoughignore_deprecated
has beed set to False by default, when we use lambda to create this mock data, we still need to assign a variable as a kind of placeholder, otherwise, there will be an error raised... can I still keep this, and remove None so that it looks likelambda: prefix, ignore_deprecated
, please share your thoughts! And thanks for the quick response! @datapythonistaThere 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.
oh, that's right, I checked it fast and didn't see those are the arguments of the mock function, not the parameters being passed. In that case set
ignore_deprecated=False
, so we have the same signature in the mock as in the mocked function.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.
oh, yeah, changed to False! thx for the feedback!