Uh oh!
There was an error while loading. Please reload this page.
Fix for Python 3.10: don't compare to sys.version string - #2076
Conversation
emmanuelle
commented
Jan 15, 2020
Thank you @hugovk. I have no idea why we excluded python 3.2 here... any idea @nicolaskruchten@jonmmease ? |
hugovk
commented
Jan 15, 2020
If it helps, it was added in PR #1476. |
nicolaskruchten
commented
Jan 15, 2020
No idea, but probably for a good reason, in which case I'd rather upgrade the check to use the right thing rather than removing it :) |
2f5a290 to
6ec6c9fComparehugovk
commented
Jan 16, 2020
Updated: - if sys.version[:3] != "3.2":+ if not sys.version_info[:2] == (3, 2): |
nicolaskruchten
commented
Jan 16, 2020
Thanks! I know my feedback is coming across as very-conservative, and I appreciate the followup :) |
| def template_doc(**names): | ||
| def _decorator(func): | ||
| if sys.version[:3] != "3.2": | ||
| if not sys.version_info[:2] == (3, 2): |
There was a problem hiding this comment.
should there be a [:2] in there? None of the changes in https://github.com/plotly/plotly.py/pull/2078/files include this index...
In fact, I think it might be nice to add this commit to #2078 and close this PR so we can merge it all at once, if you don't mind :)
There was a problem hiding this comment.
The [:2] is needed for == comparisons. It can be used but isn't required for >, >=, <, <= etc.
>>> sys.version_info
sys.version_info(major=3, minor=8, micro=1, releaselevel='final', serial=0)
>>> sys.version_info[:2]
(3, 8)
>>> sys.version_info[:2] == (3, 8)
True
>>> sys.version_info == (3, 8)
False
>>> sys.version_info >= (3, 8)
True
>>> sys.version_info[:2] >= (3, 8)
True
>>> sys.version_info >= (3, 9)
False
>>> sys.version_info[:2] >= (3, 9)
FalseYep, will combine.
There was a problem hiding this comment.
In fact, I think it might be nice to add this commit to #2078 and close this PR so we can merge it all at once, if you don't mind :)
Added, closing.
hugovk
commented
Jan 16, 2020
No problem at all, it's good to be careful with widely used code! By the way, how about (in another PR) adding python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*',Which allows install on Python 2.7 and 3.5+. https://github.com/pypa/pip/blob/fed360a64e907f3ce8f5d497cc806df2fa9a0799/setup.py#L86 |
When dealing with version numbers, it's generally safer to use the
sys.version_infotuple that thesys.versionstring.When Python 3.10 comes around (probably in May 2020 when Python 3.9 reaches beta), it will claim to be on Python 3.1!
In this case, Python 3.2 is no longer supported, so this check can be removed. (And in fact, it wouldn't have failed until Python 3.20, but it's good to clean up.)
Found with https://github.com/asottile/flake8-2020