Recognize and replace if sys.version_info[0]
blocks #918
Open
Description
pyupgrade currently does detect the if sys.version_info < (3, 5):
syntax, it doesn't recognize the lesser but still sometimes used if sys.version_info[0] < 3:
syntax in if or if-else blocks. It would be a nice feature if pyupgrade also could recognize and automatically replace such blocks.
A few examples I encountered in the wild:
if sys.version_info[0] < 3:
import shutil
shutil.rmtree(cls._tmpdir)
else:
cls._tmpdir.cleanup()
if (sys.version_info[0] >=3 and
isinstance(node, StringNode) and
node.unicode_value is not None):
return (node.unicode_value, node.pos)
return (node.compile_time_value(empty_scope), node.pos)
if sys.version_info[0] != 2:
self.assertTrue(StringEncoding.string_contains_lone_surrogates("\uD800\uDFFF"))
Metadata
Assignees
Labels
No labels