diff --git a/nova/availability_zones.py b/nova/availability_zones.py index 09cbd98b837a..711eee1faab4 100644 --- a/nova/availability_zones.py +++ b/nova/availability_zones.py @@ -17,7 +17,6 @@ from nova import db from nova.openstack.common import cfg -from nova.openstack.common import jsonutils from nova.openstack.common import log as logging availability_zone_opts = [ diff --git a/nova/compute/manager.py b/nova/compute/manager.py index dbfee2469da6..9bdab7a257e9 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -57,13 +57,11 @@ from nova import network from nova.network import model as network_model from nova.openstack.common import cfg from nova.openstack.common import excutils -from nova.openstack.common import importutils from nova.openstack.common import jsonutils from nova.openstack.common import lockutils from nova.openstack.common import log as logging from nova.openstack.common.notifier import api as notifier from nova.openstack.common import rpc -from nova.openstack.common.rpc import common as rpc_common from nova.openstack.common import timeutils from nova import paths from nova import quota diff --git a/nova/db/sqlalchemy/migrate_repo/versions/152_change_type_of_deleted_column.py b/nova/db/sqlalchemy/migrate_repo/versions/152_change_type_of_deleted_column.py index d4bd991f72b9..c49e8272b291 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/152_change_type_of_deleted_column.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/152_change_type_of_deleted_column.py @@ -4,8 +4,7 @@ from sqlalchemy.ext.compiler import compiles from sqlalchemy import MetaData, Table, Column, Index from sqlalchemy import select from sqlalchemy.sql.expression import UpdateBase -from sqlalchemy.sql import literal_column -from sqlalchemy import String, Integer, Boolean +from sqlalchemy import Integer, Boolean from sqlalchemy.types import NullType, BigInteger diff --git a/nova/exception.py b/nova/exception.py index a9a565393324..bb7749dd708c 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -25,7 +25,6 @@ SHOULD include dedicated exception logging. """ import functools -import itertools import webob.exc diff --git a/nova/network/manager.py b/nova/network/manager.py index 897472d0812b..8ee8f0290d3c 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -47,7 +47,6 @@ import datetime import itertools import math import re -import socket import uuid from eventlet import greenpool diff --git a/nova/notifications.py b/nova/notifications.py index 65428d03f154..f40fff7f2f95 100644 --- a/nova/notifications.py +++ b/nova/notifications.py @@ -21,7 +21,6 @@ the system. import nova.context from nova import db -from nova import exception from nova.image import glance from nova import network from nova.network import model as network_model diff --git a/nova/scheduler/filters/availability_zone_filter.py b/nova/scheduler/filters/availability_zone_filter.py index 585acbaf804c..390276ea36de 100644 --- a/nova/scheduler/filters/availability_zone_filter.py +++ b/nova/scheduler/filters/availability_zone_filter.py @@ -14,7 +14,6 @@ # under the License. -from nova import availability_zones from nova import db from nova.openstack.common import cfg from nova.scheduler import filters diff --git a/nova/service.py b/nova/service.py index 4fc12f374e4c..2daceba80fc9 100644 --- a/nova/service.py +++ b/nova/service.py @@ -38,7 +38,6 @@ from nova.openstack.common import eventlet_backdoor from nova.openstack.common import importutils from nova.openstack.common import log as logging from nova.openstack.common import rpc -from nova.openstack.common.rpc import common as rpc_common from nova import servicegroup from nova import utils from nova import version diff --git a/nova/servicegroup/drivers/db.py b/nova/servicegroup/drivers/db.py index 686ee728bf12..18b4b74e57de 100644 --- a/nova/servicegroup/drivers/db.py +++ b/nova/servicegroup/drivers/db.py @@ -16,7 +16,6 @@ from nova import conductor from nova import context -from nova import exception from nova.openstack.common import cfg from nova.openstack.common import log as logging from nova.openstack.common import timeutils diff --git a/nova/tests/baremetal/test_nova_baremetal_manage.py b/nova/tests/baremetal/test_nova_baremetal_manage.py index 4d152a028690..c4fdaac6bc74 100644 --- a/nova/tests/baremetal/test_nova_baremetal_manage.py +++ b/nova/tests/baremetal/test_nova_baremetal_manage.py @@ -20,10 +20,6 @@ import imp import os import sys -from nova import context -from nova import test -from nova.virt.baremetal import db as bmdb - from nova.tests.baremetal.db import base as bm_db_base TOPDIR = os.path.normpath(os.path.join( diff --git a/nova/tests/baremetal/test_pxe.py b/nova/tests/baremetal/test_pxe.py index dafa9bab7b52..09f1079bf40e 100644 --- a/nova/tests/baremetal/test_pxe.py +++ b/nova/tests/baremetal/test_pxe.py @@ -21,12 +21,10 @@ import os -import mox from testtools import matchers from nova import exception from nova.openstack.common import cfg -from nova import test from nova.tests.baremetal.db import base as bm_db_base from nova.tests.baremetal.db import utils as bm_db_utils from nova.tests.image import fake as fake_image diff --git a/nova/tests/baremetal/test_utils.py b/nova/tests/baremetal/test_utils.py index 2615a26cb9ee..df5112debabd 100644 --- a/nova/tests/baremetal/test_utils.py +++ b/nova/tests/baremetal/test_utils.py @@ -18,12 +18,9 @@ """Tests for baremetal utils.""" -import mox - import errno import os -from nova import exception from nova import test from nova.virt.baremetal import utils diff --git a/nova/tests/cells/test_cells_messaging.py b/nova/tests/cells/test_cells_messaging.py index da45721ed613..1208368c2aab 100644 --- a/nova/tests/cells/test_cells_messaging.py +++ b/nova/tests/cells/test_cells_messaging.py @@ -14,8 +14,6 @@ """ Tests For Cells Messaging module """ -import mox - from nova.cells import messaging from nova.cells import utils as cells_utils from nova import context diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index 94f297fe9303..c665aa1b358d 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -15,7 +15,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. -import shutil import fixtures import mox diff --git a/nova/tests/test_availability_zones.py b/nova/tests/test_availability_zones.py index 2c5c06921fdf..4192fa08fbbc 100644 --- a/nova/tests/test_availability_zones.py +++ b/nova/tests/test_availability_zones.py @@ -23,7 +23,6 @@ from nova import availability_zones as az from nova import context from nova import db from nova.openstack.common import cfg -from nova import service from nova import test CONF = cfg.CONF diff --git a/nova/tests/test_periodic_tasks.py b/nova/tests/test_periodic_tasks.py index 3c63f6d4ad73..621e86b3a517 100644 --- a/nova/tests/test_periodic_tasks.py +++ b/nova/tests/test_periodic_tasks.py @@ -17,7 +17,6 @@ import time -import fixtures from testtools import matchers from nova import manager diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index 6ea2d0ef7f43..e8e7c329a52e 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -119,8 +119,6 @@ class _FakeDriverBackendTestCase(object): def _teardown_fakelibvirt(self): # Restore libvirt - import nova.virt.libvirt.driver - import nova.virt.libvirt.firewall if self.saved_libvirt: sys.modules['libvirt'] = self.saved_libvirt diff --git a/nova/tests/virt/xenapi/test_vm_utils.py b/nova/tests/virt/xenapi/test_vm_utils.py index 275088af0c6b..633e6f835536 100644 --- a/nova/tests/virt/xenapi/test_vm_utils.py +++ b/nova/tests/virt/xenapi/test_vm_utils.py @@ -19,10 +19,8 @@ import contextlib import fixtures import mox -import uuid from nova import test -from nova.tests.xenapi import stubs from nova import utils from nova.virt.xenapi import vm_utils diff --git a/nova/virt/baremetal/pxe.py b/nova/virt/baremetal/pxe.py index 11af99d41c06..5a6f5865528d 100644 --- a/nova/virt/baremetal/pxe.py +++ b/nova/virt/baremetal/pxe.py @@ -27,11 +27,9 @@ from nova import exception from nova.openstack.common import cfg from nova.openstack.common import fileutils from nova.openstack.common import log as logging -from nova import utils from nova.virt.baremetal import base from nova.virt.baremetal import db from nova.virt.baremetal import utils as bm_utils -from nova.virt.disk import api as disk pxe_opts = [ diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py index d90a5e2952e5..eb16148739cf 100644 --- a/nova/virt/libvirt/vif.py +++ b/nova/virt/libvirt/vif.py @@ -28,7 +28,7 @@ from nova import utils from nova.virt.libvirt import config as vconfig from nova.virt.libvirt import designer -from nova.virt import netutils + LOG = logging.getLogger(__name__) libvirt_vif_opts = [ diff --git a/nova/virt/powervm/blockdev.py b/nova/virt/powervm/blockdev.py index fb3a0210c82e..76caca1b968b 100644 --- a/nova/virt/powervm/blockdev.py +++ b/nova/virt/powervm/blockdev.py @@ -18,16 +18,11 @@ import hashlib import os import re -from eventlet import greenthread - -from nova import utils - from nova.image import glance - from nova.openstack.common import cfg from nova.openstack.common import excutils from nova.openstack.common import log as logging - +from nova import utils from nova.virt import images from nova.virt.powervm import command from nova.virt.powervm import common diff --git a/nova/virt/powervm/driver.py b/nova/virt/powervm/driver.py index ccba3cf736ef..0ce31353501d 100644 --- a/nova/virt/powervm/driver.py +++ b/nova/virt/powervm/driver.py @@ -14,19 +14,11 @@ # License for the specific language governing permissions and limitations # under the License. -import os import time -from nova.compute import task_states -from nova.compute import vm_states - -from nova import context as nova_context - from nova.image import glance - from nova.openstack.common import cfg from nova.openstack.common import log as logging - from nova.virt import driver from nova.virt.powervm import operator diff --git a/nova/virt/vmwareapi/host.py b/nova/virt/vmwareapi/host.py index 424dac707c08..09b8f1fe3264 100644 --- a/nova/virt/vmwareapi/host.py +++ b/nova/virt/vmwareapi/host.py @@ -18,8 +18,6 @@ Management class for host-related functions (start, reboot, etc). """ -import json - from nova import exception from nova.openstack.common import log as logging from nova.virt.vmwareapi import vim_util diff --git a/nova/virt/vmwareapi/vmops.py b/nova/virt/vmwareapi/vmops.py index 5ea9f105cb02..75f85454b4cb 100644 --- a/nova/virt/vmwareapi/vmops.py +++ b/nova/virt/vmwareapi/vmops.py @@ -35,9 +35,7 @@ from nova import context as nova_context from nova import exception from nova.openstack.common import cfg from nova.openstack.common import excutils -from nova.openstack.common import importutils from nova.openstack.common import log as logging -from nova.openstack.common import timeutils from nova.virt import driver from nova.virt.vmwareapi import network_util from nova.virt.vmwareapi import vif as vmwarevif diff --git a/nova/virt/vmwareapi/volume_util.py b/nova/virt/vmwareapi/volume_util.py index 9d556cd26cb6..2af3381a4ed3 100644 --- a/nova/virt/vmwareapi/volume_util.py +++ b/nova/virt/vmwareapi/volume_util.py @@ -22,7 +22,6 @@ and storage repositories import re import string -from nova import exception from nova.openstack.common import log as logging from nova.virt.vmwareapi import vim_util diff --git a/run_tests.sh b/run_tests.sh index 11bc8b518e2b..5bb2842b270e 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -142,6 +142,7 @@ function run_pep8 { echo "Running pep8" ${wrapper} python tools/hacking.py ${ignore} ${srcfiles} + ${wrapper} bash tools/unused_imports.sh # NOTE(sdague): as of grizzly-2 these are passing however leaving the comment # in here in case we need to break it out when we get more of our hacking working # again. diff --git a/tools/flakes.py b/tools/flakes.py index 4b93abc2109d..f805fd15645f 100644 --- a/tools/flakes.py +++ b/tools/flakes.py @@ -8,7 +8,7 @@ import __builtin__ import os import sys -from pyflakes.scripts.pyflakes import main +from pyflakes.scripts import pyflakes if __name__ == "__main__": names = os.environ.get('PYFLAKES_BUILTINS', '_') @@ -19,4 +19,4 @@ if __name__ == "__main__": del names, os, __builtin__ - sys.exit(main()) + sys.exit(pyflakes.main()) diff --git a/tools/unused_imports.sh b/tools/unused_imports.sh new file mode 100755 index 000000000000..0e0294517d27 --- /dev/null +++ b/tools/unused_imports.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +#snakefood sfood-checker detects even more unused imports +! pyflakes nova/ | grep "imported but unused" diff --git a/tox.ini b/tox.ini index e98f301515b8..67fe1eea0266 100644 --- a/tox.ini +++ b/tox.ini @@ -15,13 +15,16 @@ sitepackages = True downloadcache = ~/cache/pip [testenv:pep8] -deps=pep8==1.3.3 +deps= + pep8==1.3.3 + pyflakes commands = python tools/hacking.py --doctest python tools/hacking.py --ignore=E12,E711,E721,E712,N403,N404 --show-source \ --exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg . python tools/hacking.py --ignore=E12,E711,E721,E712,N403,N404 --show-source \ --filename=nova* bin + bash tools/unused_imports.sh [testenv:pylint] setenv = VIRTUAL_ENV={envdir}