Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Impala 4.3.0
-
None
-
ghx-label-7
Description
Python 3 changed the way imports work so that imports in modules need to be absolute. To make our Python 2 behave like Python 3, we can add "from _future_ import absolute_import" to our python files. More details here: https://python-future.org/compatible_idioms.html#imports-relative-to-a-package
Python 3 also changed the default behavior of division to use float division in more circumstances (i.e. 1 / 2 is 0.5 rather than 0). To make Python 2 behave like Python 3, we can add "from _future_ import division" to our python files. Locations that need the old integer division can use '//'. More details here: https://python-future.org/compatible_idioms.html#division
Since both involve adding an import to all files, doing them together reduces the disruption.
These correspond to the no-absolute-import and old-division checks in Pylint. For old division, Pylint can point out locations that may need to be modified, and that needs to happen before adding the division import.