-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: Use pandas.compat instead of sys.version_info for Python version checks #20545
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
@@ -2088,7 +2088,7 @@ def dec(f): | |||
# and conditionally raise on these exception types | |||
_network_error_classes = (IOError, httplib.HTTPException) | |||
|
|||
if sys.version_info >= (3, 3): | |||
if PY3: |
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.
Since 3.0 - 3.4 are no longer supported, seems fine to use PY3
. Could use PY35
if being explicit would be preferred here (or maybe just leave as-is).
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'm fine with this change. We should be encouraging code that relies solely on the supported versions of Python and not do the C-esque thing of making it super-backwards-compatible 😄
@@ -104,7 +103,7 @@ def test_cant_compare_tz_naive_w_aware(self): | |||
pytest.raises(Exception, b.__lt__, a) | |||
pytest.raises(Exception, b.__gt__, a) | |||
|
|||
if sys.version_info < (3, 3): | |||
if PY2: |
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.
Likewise, <3.3 implies PY2
based on the currently supported versions. Could be more explicit if desired though.
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's reasonable. 2.7, 3.5 - 3.6 are the only supported versions.
Codecov Report
@@ Coverage Diff @@
## master #20545 +/- ##
==========================================
- Coverage 91.84% 91.81% -0.03%
==========================================
Files 152 152
Lines 49268 49266 -2
==========================================
- Hits 45250 45236 -14
- Misses 4018 4030 +12
Continue to review full report at Codecov.
|
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.
Thanks for the clean-up!
lgtm. the only thing would add is if you can fail |
I can add a check for this to
This would get caught by |
we have a PY35 already. guess could just exclude this file) The lint check just enforces that the code all uses the same pattern, don't like to have people making up ways to do very standard things (and docs on how to do things like this, while helpful, get out of date), better to have an actual check. no |
The example I showed is actually different than That actually looks like the only oddly specific case of a version check. The only other non- pandas/pandas/util/_print_versions.py Line 41 in 0a00365
Could either skip that file or create a variable like |
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 fixes!
yeah have special cases is a bit annoying. how about you just remove the remaining ones that are possible? and leave lint.sh alone is ok. |
Added some small fixes for the remaining easily removable instances of |
great. can you rebase. just merged a patch which conflicts. |
pandas/tests/io/parser/common.py
Outdated
@@ -1277,8 +1277,7 @@ def test_verbose_import(self): | |||
|
|||
def test_iteration_open_handle(self): |
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.
can you change this to a pytest.mark.skip decorator
cfa5a45
to
6cf2e98
Compare
rebased and made the requested change |
thanks! |
Hopefully this will make code changes related to dropping support for specific versions of Python slightly easier to identify.
Summary:
sys.version_info
with equivalent checks frompandas.compat
There were some very specific examples that I left as-is:
pandas/pandas/tests/io/formats/test_to_csv.py
Line 13 in c4b4a81
Didn't change any Cython related code, as it appears that we want to avoid imports from outside
_libs
:pandas/pandas/_libs/tslibs/parsing.pyx
Lines 25 to 26 in c4b4a81