From 64e3c4116720531d69a522d1b056636a0b0065b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Beraud?= Date: Tue, 2 Jun 2020 20:14:31 +0200 Subject: [PATCH] Stop to use the __future__ module. The __future__ module [1] was used in this context to ensure compatibility between python 2 and python 3. We previously dropped the support of python 2.7 [2] and now we only support python 3 so we don't need to continue to use this module and the imports listed below. Imports commonly used and their related PEPs: - `division` is related to PEP 238 [3] - `print_function` is related to PEP 3105 [4] - `unicode_literals` is related to PEP 3112 [5] - `with_statement` is related to PEP 343 [6] - `absolute_import` is related to PEP 328 [7] [1] https://docs.python.org/3/library/__future__.html [2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html [3] https://www.python.org/dev/peps/pep-0238 [4] https://www.python.org/dev/peps/pep-3105 [5] https://www.python.org/dev/peps/pep-3112 [6] https://www.python.org/dev/peps/pep-0343 [7] https://www.python.org/dev/peps/pep-0328 Change-Id: I82b61a2d7687ff109051815e01619eb612ea9073 --- glance/cmd/cache_manage.py | 1 - glance/cmd/control.py | 3 --- glance/cmd/manage.py | 2 -- glance/cmd/replicator.py | 2 -- glance/common/wsgi.py | 1 - glance/db/sqlalchemy/alembic_migrations/env.py | 2 -- glance/image_cache/drivers/sqlite.py | 2 -- glance/image_cache/drivers/xattr.py | 2 -- glance/tests/functional/store_utils.py | 2 -- glance/tests/unit/fixtures.py | 1 - glance/tests/unit/test_glance_replicator.py | 2 -- glance/tests/unit/test_image_cache.py | 2 -- glance/tests/unit/test_manage.py | 2 -- 13 files changed, 24 deletions(-) diff --git a/glance/cmd/cache_manage.py b/glance/cmd/cache_manage.py index 23f7e982d6..f7f3968aff 100644 --- a/glance/cmd/cache_manage.py +++ b/glance/cmd/cache_manage.py @@ -18,7 +18,6 @@ """ A simple cache management utility for Glance. """ -from __future__ import print_function import argparse import collections diff --git a/glance/cmd/control.py b/glance/cmd/control.py index 64a26635ab..33405c36ab 100644 --- a/glance/cmd/control.py +++ b/glance/cmd/control.py @@ -18,9 +18,6 @@ Helper script for starting/stopping/reloading Glance server programs. Thanks for some of the code, Swifties ;) """ -from __future__ import print_function -from __future__ import with_statement - import argparse import fcntl import os diff --git a/glance/cmd/manage.py b/glance/cmd/manage.py index cc2fdc3c50..31087e8a65 100644 --- a/glance/cmd/manage.py +++ b/glance/cmd/manage.py @@ -21,8 +21,6 @@ Glance Management Utility """ -from __future__ import print_function - # FIXME(sirp): When we have glance-admin we can consider merging this into it # Perhaps for consistency with Nova, we would then rename glance-admin -> # glance-manage (or the other way around) diff --git a/glance/cmd/replicator.py b/glance/cmd/replicator.py index f2d2ae6b1f..e8fd47c711 100644 --- a/glance/cmd/replicator.py +++ b/glance/cmd/replicator.py @@ -16,8 +16,6 @@ # License for the specific language governing permissions and limitations # under the License. -from __future__ import print_function - import os import sys diff --git a/glance/common/wsgi.py b/glance/common/wsgi.py index 8f947be6ad..60971ad986 100644 --- a/glance/common/wsgi.py +++ b/glance/common/wsgi.py @@ -19,7 +19,6 @@ """ Utility methods for working with WSGI servers """ -from __future__ import print_function import abc import errno diff --git a/glance/db/sqlalchemy/alembic_migrations/env.py b/glance/db/sqlalchemy/alembic_migrations/env.py index 554aa5a943..a474009e8a 100644 --- a/glance/db/sqlalchemy/alembic_migrations/env.py +++ b/glance/db/sqlalchemy/alembic_migrations/env.py @@ -12,8 +12,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - -from __future__ import with_statement from logging import config as log_config from alembic import context diff --git a/glance/image_cache/drivers/sqlite.py b/glance/image_cache/drivers/sqlite.py index 4bed3c753d..1fe6d10539 100644 --- a/glance/image_cache/drivers/sqlite.py +++ b/glance/image_cache/drivers/sqlite.py @@ -16,8 +16,6 @@ """ Cache driver that uses SQLite to store information about cached images """ - -from __future__ import absolute_import from contextlib import contextmanager import os import sqlite3 diff --git a/glance/image_cache/drivers/xattr.py b/glance/image_cache/drivers/xattr.py index 89a397ddc8..a2e8af907d 100644 --- a/glance/image_cache/drivers/xattr.py +++ b/glance/image_cache/drivers/xattr.py @@ -50,8 +50,6 @@ $image_cache_dir/ invalid/ queue/ """ - -from __future__ import absolute_import from contextlib import contextmanager import errno import os diff --git a/glance/tests/functional/store_utils.py b/glance/tests/functional/store_utils.py index 701bead1c2..fd3275b1c4 100644 --- a/glance/tests/functional/store_utils.py +++ b/glance/tests/functional/store_utils.py @@ -18,8 +18,6 @@ Utility methods to set testcases up for Swift tests. """ -from __future__ import print_function - import threading from oslo_utils import units diff --git a/glance/tests/unit/fixtures.py b/glance/tests/unit/fixtures.py index 420135f93f..e6e48c32c5 100644 --- a/glance/tests/unit/fixtures.py +++ b/glance/tests/unit/fixtures.py @@ -12,7 +12,6 @@ """Fixtures for Glance unit tests.""" # NOTE(mriedem): This is needed for importing from fixtures. -from __future__ import absolute_import import logging as std_logging import os diff --git a/glance/tests/unit/test_glance_replicator.py b/glance/tests/unit/test_glance_replicator.py index a98bca696a..5b0896faa0 100644 --- a/glance/tests/unit/test_glance_replicator.py +++ b/glance/tests/unit/test_glance_replicator.py @@ -11,8 +11,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - -from __future__ import absolute_import from unittest import mock import copy diff --git a/glance/tests/unit/test_image_cache.py b/glance/tests/unit/test_image_cache.py index 42535ba8e8..bfdef3d684 100644 --- a/glance/tests/unit/test_image_cache.py +++ b/glance/tests/unit/test_image_cache.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -from __future__ import absolute_import - from contextlib import contextmanager import datetime import hashlib diff --git a/glance/tests/unit/test_manage.py b/glance/tests/unit/test_manage.py index 882cf36cc9..2ebd2c9b05 100644 --- a/glance/tests/unit/test_manage.py +++ b/glance/tests/unit/test_manage.py @@ -12,8 +12,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - -from __future__ import absolute_import from unittest import mock import fixtures