-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
DOC: Add ignore-deprecate argument to validate_docstrings.py #23650
DOC: Add ignore-deprecate argument to validate_docstrings.py #23650
Conversation
Hello @charlesdong1991! Thanks for updating the PR.
Comment last updated on November 13, 2018 at 12:55 Hours UTC |
Thanks for the PR. Sorry the issue wasn't clear. Let me explain clear better...
This is useful only when validating all the docstrings. That, instead of validating 100% of them, we can validate only the ones not deprecated (we don't care that much about errors in the docstrings of deprecated methods, as we are going to delete them in few weeks). I think you did something different here, if I'm not wrong. Btw, you should replace in the pull request description the Please let me know if you need additional info. |
scripts/validate_docstrings.py
Outdated
@@ -838,8 +842,16 @@ def header(title, width=80, char='#'): | |||
'list of error codes to validate. By default it ' | |||
'validates all errors (ignored when validating ' | |||
'a single docstring)') | |||
argparser.add_argument('--deprecated', default=False, type=bool, |
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.
The argument name should probably be --ignore-deprecated
, and just deprecated is not very clear
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.
That looks great now, sorry for the bad communication initially. Just added couple of comments about argparse
.
scripts/validate_docstrings.py
Outdated
@@ -838,8 +842,16 @@ def header(title, width=80, char='#'): | |||
'list of error codes to validate. By default it ' | |||
'validates all errors (ignored when validating ' | |||
'a single docstring)') | |||
argparser.add_argument('--ignore_deprecated', default=False, type=bool, |
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.
Not a big difference, but I think in this case it's better to use action='store_true'
. I think with type=bool
we can have unexpected behavior like --ignore-deprecated=false
meaning actually true.
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.
yes, i also feel confused... because set it to true actually means we won't store it...
changed...
scripts/validate_docstrings.py
Outdated
'the function or method will be deprecated ' | ||
'in later version. Default is True, means if the ' | ||
'function will be deprecated, the docstring will ' | ||
'not be displayed in the output of script') |
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.
I think we can now simplify this description to something like if this flag is set, deprecated objects are ignored when validating all docstrings
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.
nice one! the description looks much clear now!! thx!!!
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.
lgtm, nice PR @charlesdong1991, thanks for the work on this
thank you @datapythonista excited to learn from you!! |
HI, @datapythonista sorry to bother, i have struggle at this point for a while and tried quite many times to complete the pytest, however, seems that this deprecated is not working... https://travis-ci.org/charlesdong1991/pandas/jobs/454651182 |
If I remember correctly, the exit status is the number of errors, not the number of docstrings failing. So, it should be 3, as one docstring generates 2 errors, the other 1, and the other is ignored because it's deprecated, so it will generate 0. Does that make sense? |
Hello, @datapythonista thank you very much for your quick response! Yes, i think exit status is the number of errors, however, in my case, i specified the error parameter to "ER01" which means it will only count the errors that are ER01, so in this case, only two will be chosen, because although the first docstring contains ER01, it's deprecated, so should not be counted. please correct me if i understand incorrectly. |
I think the problem with the test is that the filtering is happening inside of |
@datapythonista agree! i am thinking about the same, i also doubt if i should test the main... but i haven't found any test class or functions for validate_all? any suggestions on which is the best way to test? shall i create mock data as input and set deprecated to True, and then count the length of dictionary of outcome to see if the length is reduced accordingly to the deprecation? |
I do think we have tests where we mock |
Hi, @datapythonista sorry to bother you again, i made new changes on pytest, and yesterday it seemed work and passed tests... however, today when i am trying to complete PR, i see some other errors that should not be caused by my change... |
i removed the test part, and the error remains the same |
Can't check the travis log from my phone, but it happens some times that things fail because of things unrelated to your PR. Just leave your changes ready, and merge master in to your branch after some hours since the failure, and see if it's fixed. Sometimes it can be that Anaconda is failing to download, a dependency released a new version that breaks something, problems in the Travis servers, something broken merged into master... |
e6cb8d0
to
83cc28c
Compare
Codecov Report
@@ Coverage Diff @@
## master #23650 +/- ##
==========================================
+ Coverage 92.24% 92.25% +<.01%
==========================================
Files 161 161
Lines 51336 51383 +47
==========================================
+ Hits 47357 47404 +47
Misses 3979 3979
Continue to review full report at Codecov.
|
Hi, @datapythonista from my side, it looks like it passed all, |
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.
Looks good, couple of formatting things
scripts/validate_docstrings.py
Outdated
@@ -733,6 +733,9 @@ def validate_all(prefix): | |||
If provided, only the docstrings that start with this pattern will be | |||
validated. If None, all docstrings will be validated. | |||
|
|||
ignore_deprecated: Boolean variable |
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.
ignore_deprecated: Boolean variable | |
ignore_deprecated : bool, default False |
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.
thanks for the correction!
scripts/validate_docstrings.py
Outdated
@@ -733,6 +733,9 @@ def validate_all(prefix): | |||
If provided, only the docstrings that start with this pattern will be | |||
validated. If None, all docstrings will be validated. | |||
|
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.
Remove this blank line
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.
removed!
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Move the curly bracket to the previous line
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.
did it!
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: { |
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 of False
that is what we want. So, can you restore the original code? I think it should work, right?
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 although ignore_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 like lambda: prefix, ignore_deprecated
, please share your thoughts! And thanks for the quick response! @datapythonista
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, 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!
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 comment
The reason will be displayed to describe this comment to others. Learn more.
same here, and in the rest of cases
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.
lgtm, let's see if all tests pass now.
Thanks for the work on this @charlesdong1991
@datapythonista yeah, it passed! thx very much for your help!! |
Tanks for the contribution @charlesdong1991. I'll let another maintainer double check the changes and merge them, but all good from my side. |
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.
Looks good to me!
…fixed * upstream/master: (46 commits) DEPS: bump xlrd min version to 1.0.0 (pandas-dev#23774) BUG: Don't warn if default conflicts with dialect (pandas-dev#23775) BUG: Fixing memory leaks in read_csv (pandas-dev#23072) TST: Extend datetime64 arith tests to array classes, fix several broken cases (pandas-dev#23771) STYLE: Specify bare exceptions in pandas/tests (pandas-dev#23370) ENH: between_time, at_time accept axis parameter (pandas-dev#21799) PERF: Use is_utc check to improve performance of dateutil UTC in DatetimeIndex methods (pandas-dev#23772) CLN: io/formats/html.py: refactor (pandas-dev#22726) API: Make Categorical.searchsorted returns a scalar when supplied a scalar (pandas-dev#23466) TST: Add test case for GH14080 for overflow exception (pandas-dev#23762) BUG: Don't extract header names if none specified (pandas-dev#23703) BUG: Index.str.partition not nan-safe (pandas-dev#23558) (pandas-dev#23618) DEPR: tz_convert in the Timestamp constructor (pandas-dev#23621) PERF: Datetime/Timestamp.normalize for timezone naive datetimes (pandas-dev#23634) TST: Use new arithmetic fixtures, parametrize many more tests (pandas-dev#23757) REF/TST: Add more pytest idiom to parsers tests (pandas-dev#23761) DOC: Add ignore-deprecate argument to validate_docstrings.py (pandas-dev#23650) ENH: update pandas-gbq to 0.8.0, adds credentials arg (pandas-dev#23662) DOC: Improve error message to show correct order (pandas-dev#23652) ENH: Improve error message for empty object array (pandas-dev#23718) ...
git diff upstream/master -u -- "*.py" | flake8 --diff