version_info.major >= 3 and version_info.minor >= 5
hugovk opened this issue · 2 comments
hugovk commented
This is used in three places in scipy, and I've seen this sort of thing in other repos too:
if sys.version_info.major >= 3 and sys.version_info.minor >= 5:
from math import gcd
else:
from fractions import gcd
The if
is incorrectly False
for 4.0 - 4.4, 5.0 - 5.4, etc.
To fix:
-if sys.version_info.major >= 3 and sys.version_info.minor >= 5:
+if sys.version_info >= (3, 5):
from math import gcd
else:
from fractions import gcd
Can this easily be detected?
asottile commented
yep! should be detectable by looking for just the comparison to minor version (which by itself is unsafe)
should look for both sys.version_info.minor
as well as sys.version_info[1]
and report a YTT20X
code
would you like to work on a patch for this?
hugovk commented
Yep, I'll have a go!