-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
TYP: Remove pandas.io.stata from Typing Blacklist #25940
TYP: Remove pandas.io.stata from Typing Blacklist #25940
Conversation
Codecov Report
@@ Coverage Diff @@
## master #25940 +/- ##
==========================================
- Coverage 91.81% 91.81% -0.01%
==========================================
Files 175 175
Lines 52580 52580
==========================================
- Hits 48278 48274 -4
- Misses 4302 4306 +4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #25940 +/- ##
==========================================
- Coverage 91.84% 91.83% -0.01%
==========================================
Files 175 175
Lines 52517 52517
==========================================
- Hits 48232 48228 -4
- Misses 4285 4289 +4
Continue to review full report at Codecov.
|
@ryankarlos what failure are you getting when removing? |
d2a8770
to
1d96fec
Compare
I think the error was linked to validate_docstrings.py which parses the doc/source/reference/io.rst file to do the docstring validation on all the methods in io - there is a reference to StataReader.data_label there, so it is throwing an error 'StataReader' has no attribute 'data_label' because I had removed this method. Should I just remove it from this reference file as well - not sure about any other dependencies on this ? |
@WillAyd All green now after the fix. |
Hmm not sure this is the right solution - would it actually make more sense to assign to |
cc @bashtage |
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 needs to be a private attribute (_data_label) I think.
If you don't want to change the API, then switch TBH it might as well be an attribute or a property, but this would break an API that is probably almost never used.*
|
Thanks, makes sense - ill push the changes |
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.
There are still a few other assignments to self.data_label
in the module - can you check them all?
The attribute seems to have precedence over the method, and so the public attribute should be retained and the method deleted. |
@bashtage just to clarify, are you saying better to revert back to the previous solution i.e switching back to |
Yes. I just tried in master and Stata reader has an accessible attribute,
not a method. You should not need to change the tests (and the api) to add
typing.
…On Thu, Apr 4, 2019, 00:44 Ryan Nazareth ***@***.***> wrote:
@bashtage <https://github.com/bashtage> just to clarify, are you saying
better to revert back to the previous solution i.e switching back to
self.data_label assignment ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#25940 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFU5RQ9xDV2-5eutwRsFwaNo6kLxQiXTks5vdTzwgaJpZM4cUIra>
.
|
The method is documented as part of the API: http://pandas.pydata.org/pandas-docs/stable/reference/io.html#stata I agree that would be strange to use when compared against the attribute, but at the same time the method is what is exposed / documented so changing that would require a lot more effort / deprecation |
@WillAyd The documentation is wrong and should be fixed. Any user who is using this feature will get their code broken by a move to a method, and so introducing a method is a defacto API change.
produces
|
Hmm OK interesting - thanks for confirming that. I suppose this is a strange in between of a instance variable and method which are two distinct things but probably should have been managed via a property. Given the instance variable is populate from a private method I suppose it's not supposed to be exposed as part of the API 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.
A simple solution is to keep private attribute changes and then the switch data label to a property.
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.
aside from the @bashtage changes, pls explain why we cannot leave the
from pandas import .....
I find this easier to read.
Does this need to be reverted as well ? Was of the impression that the requirements in this issue were to explicitly import as defined internally ? Happy to revert though if not the case
|
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
…m mypy.ini blacklist
… error" This reverts commit 9ae0804.
df8beec
to
4a58142
Compare
Not sure why CI is failing. |
…ping_fix_pandas.io.stata
@WillAyd All green now |
Great thanks! I think we need a precursor to this PR to explicitly import objects in the top level of the code base instead of changing the import machinery here - any interest in tackling that? |
Sure, but would this be for the entire codebase or just this module ? i may need some help if i get stuck (the import machinery is more complicated than i thought it would be). just to clarify , do you want me to revert the import changes back to from |
I think OK to start with just the module and we can iterate from there to get more as needed. Starting small is always better and can expand as needed from there
Yes but after the precursor of step one is done
So the precursor will only affect modules that throw an error like "Module 'pandas' has no attribute 'XXX'" - you can certainly still work on other modules without that error and they will be unaffected Just a heads up I have limited availability until Tuesday so I can help with little things here and there but may be delayed in responding |
Ok thanks for the info, I have just made a PR #26017
|
@ryankarlos can you merge master |
…ping_fix_pandas.io.stata
thanks @ryankarlos |
git diff upstream/master -u -- "*.py" | flake8 --diff