From 3fc760ad240181eb1133e1ee2b51772ad6dca15e Mon Sep 17 00:00:00 2001 From: Ilya Shakhat Date: Mon, 20 Apr 2020 12:40:44 +0200 Subject: Enforce order of import statements This patch adds flake8-import-order plugin and fixes all found issues. Change-Id: Ibbeae4afeb737401de48fb2e7e225eb0a969908b --- osprofiler/cmd/commands.py | 4 ++-- osprofiler/drivers/elasticsearch_driver.py | 2 +- osprofiler/drivers/redis_driver.py | 1 - osprofiler/profiler.py | 2 +- osprofiler/tests/unit/test_initializer.py | 3 ++- test-requirements.txt | 1 + tox.ini | 2 ++ 7 files changed, 9 insertions(+), 6 deletions(-) diff --git a/osprofiler/cmd/commands.py b/osprofiler/cmd/commands.py index df92a56..c4750a5 100644 --- a/osprofiler/cmd/commands.py +++ b/osprofiler/cmd/commands.py @@ -15,11 +15,11 @@ import json import os -import prettytable -import six from oslo_utils import encodeutils from oslo_utils import uuidutils +import prettytable +import six from osprofiler.cmd import cliutils from osprofiler.drivers import base diff --git a/osprofiler/drivers/elasticsearch_driver.py b/osprofiler/drivers/elasticsearch_driver.py index c24eb60..2e80fe0 100644 --- a/osprofiler/drivers/elasticsearch_driver.py +++ b/osprofiler/drivers/elasticsearch_driver.py @@ -13,9 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_config import cfg import six.moves.urllib.parse as parser -from oslo_config import cfg from osprofiler.drivers import base from osprofiler import exc diff --git a/osprofiler/drivers/redis_driver.py b/osprofiler/drivers/redis_driver.py index c54b37b..4c1fc62 100644 --- a/osprofiler/drivers/redis_driver.py +++ b/osprofiler/drivers/redis_driver.py @@ -15,7 +15,6 @@ # under the License. from debtcollector import removals - from oslo_config import cfg from oslo_serialization import jsonutils import six.moves.urllib.parse as parser diff --git a/osprofiler/profiler.py b/osprofiler/profiler.py index 3748c16..42bcc28 100644 --- a/osprofiler/profiler.py +++ b/osprofiler/profiler.py @@ -17,12 +17,12 @@ import collections import datetime import functools import inspect -import six import socket import threading from oslo_utils import reflection from oslo_utils import uuidutils +import six from osprofiler import _utils as utils from osprofiler import notifier diff --git a/osprofiler/tests/unit/test_initializer.py b/osprofiler/tests/unit/test_initializer.py index ef8169a..21d20c3 100644 --- a/osprofiler/tests/unit/test_initializer.py +++ b/osprofiler/tests/unit/test_initializer.py @@ -10,9 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. -import testtools from unittest import mock +import testtools + from osprofiler import initializer diff --git a/test-requirements.txt b/test-requirements.txt index cb4349a..fe8a322 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,5 @@ hacking>=3.0,<3.1.0 # Apache-2.0 +flake8-import-order==0.18.1 # LGPLv3 coverage>=4.0 # Apache-2.0 ddt>=1.0.1 # MIT diff --git a/tox.ini b/tox.ini index 7baedc7..722d2fa 100644 --- a/tox.ini +++ b/tox.ini @@ -62,6 +62,8 @@ commands = bandit -r osprofiler -n5 show-source = true builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools,setup.py,build,releasenotes +import-order-style = pep8 +application-import-names = osprofiler [flake8:local-plugins] extension = -- cgit v1.2.1