You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@impala.apache.org by "Joe McDonnell (Jira)" <ji...@apache.org> on 2023/03/09 17:37:00 UTC

[jira] [Resolved] (IMPALA-11973) Add absolute_import and division __future__ imports to all python code

     [ https://issues.apache.org/jira/browse/IMPALA-11973?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joe McDonnell resolved IMPALA-11973.
------------------------------------
    Fix Version/s: Impala 4.3.0
         Assignee: Joe McDonnell
       Resolution: Fixed

> Add absolute_import and division __future__ imports to all python code
> ----------------------------------------------------------------------
>
>                 Key: IMPALA-11973
>                 URL: https://issues.apache.org/jira/browse/IMPALA-11973
>             Project: IMPALA
>          Issue Type: Sub-task
>          Components: Infrastructure
>    Affects Versions: Impala 4.3.0
>            Reporter: Joe McDonnell
>            Assignee: Joe McDonnell
>            Priority: Major
>             Fix For: Impala 4.3.0
>
>
> 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.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)