From a8a87900cf99e8759849a274d5ac19baa2e7f0f7 Mon Sep 17 00:00:00 2001 From: Sergey Nikitin Date: Tue, 20 Jan 2015 18:05:47 +0300 Subject: [PATCH] Enable check for H238 rule Fix H238 failures and enable check for H238 H238 old style class declaration, use new style (inherit from `object`) Change-Id: I71dd353ab260a513c5df5af0ee07754e23878570 --- nova/api/metadata/base.py | 2 +- nova/compute/resources/__init__.py | 2 +- nova/objects/base.py | 2 +- nova/objects/fields.py | 3 ++- nova/tests/unit/api/openstack/fakes.py | 2 +- nova/tests/unit/api/openstack/test_wsgi.py | 2 +- nova/tests/unit/api/test_auth.py | 2 +- nova/tests/unit/fake_network.py | 2 +- nova/tests/unit/fake_volume.py | 6 ++--- .../unit/monkey_patch_example/example_a.py | 2 +- .../unit/monkey_patch_example/example_b.py | 2 +- nova/tests/unit/objects/test_fields.py | 2 +- nova/tests/unit/virt/libvirt/test_driver.py | 26 +++++++++---------- nova/tests/unit/virt/libvirt/test_firewall.py | 4 +-- nova/tests/unit/virt/vmwareapi/stubs.py | 6 ++--- nova/tests/unit/virt/vmwareapi/test_vmops.py | 2 +- nova/tests/unit/virt/xenapi/test_agent.py | 2 +- nova/tests/unit/virt/xenapi/test_vm_utils.py | 2 +- nova/tests/unit/virt/xenapi/test_xenapi.py | 2 +- nova/virt/xenapi/fake.py | 2 +- tox.ini | 2 +- 21 files changed, 39 insertions(+), 38 deletions(-) diff --git a/nova/api/metadata/base.py b/nova/api/metadata/base.py index b042651f5407..5e799031203c 100644 --- a/nova/api/metadata/base.py +++ b/nova/api/metadata/base.py @@ -96,7 +96,7 @@ class InvalidMetadataPath(Exception): pass -class InstanceMetadata(): +class InstanceMetadata(object): """Instance metadata.""" def __init__(self, instance, address=None, content=None, extra_md=None, diff --git a/nova/compute/resources/__init__.py b/nova/compute/resources/__init__.py index e8ab37fc6204..49b8032a59cf 100644 --- a/nova/compute/resources/__init__.py +++ b/nova/compute/resources/__init__.py @@ -23,7 +23,7 @@ LOG = logging.getLogger(__name__) RESOURCE_NAMESPACE = 'nova.compute.resources' -class ResourceHandler(): +class ResourceHandler(object): def _log_missing_plugins(self, names): for name in names: diff --git a/nova/objects/base.py b/nova/objects/base.py index 7d5f4406c1c9..7d3cdc09ad0d 100644 --- a/nova/objects/base.py +++ b/nova/objects/base.py @@ -39,7 +39,7 @@ from nova import utils LOG = logging.getLogger('object') -class NotSpecifiedSentinel: +class NotSpecifiedSentinel(object): pass diff --git a/nova/objects/fields.py b/nova/objects/fields.py index 26a1c0768be4..87c9940885bb 100644 --- a/nova/objects/fields.py +++ b/nova/objects/fields.py @@ -46,7 +46,8 @@ class ElementTypeError(TypeError): }) -class AbstractFieldType(six.with_metaclass(abc.ABCMeta, object)): +@six.add_metaclass(abc.ABCMeta) +class AbstractFieldType(object): @abc.abstractmethod def coerce(self, obj, attr, value): """This is called to coerce (if possible) a value on assignment. diff --git a/nova/tests/unit/api/openstack/fakes.py b/nova/tests/unit/api/openstack/fakes.py index e48d9da8d3c5..9976c38444c0 100644 --- a/nova/tests/unit/api/openstack/fakes.py +++ b/nova/tests/unit/api/openstack/fakes.py @@ -217,7 +217,7 @@ def stub_out_nw_api(stubs, cls=None, private=None, publics=None): if not publics: publics = ['1.2.3.4'] - class Fake: + class Fake(object): def get_instance_nw_info(*args, **kwargs): pass diff --git a/nova/tests/unit/api/openstack/test_wsgi.py b/nova/tests/unit/api/openstack/test_wsgi.py index 097faa6d8f81..f356f800e355 100644 --- a/nova/tests/unit/api/openstack/test_wsgi.py +++ b/nova/tests/unit/api/openstack/test_wsgi.py @@ -503,7 +503,7 @@ class ResourceTest(test.NoDBTestCase): '{"barAction": true}') def test_get_method_action_method(self): - class Controller(): + class Controller(object): def action(self, req, pants=None): return pants diff --git a/nova/tests/unit/api/test_auth.py b/nova/tests/unit/api/test_auth.py index 0da727fef7da..28f4c50d8d7c 100644 --- a/nova/tests/unit/api/test_auth.py +++ b/nova/tests/unit/api/test_auth.py @@ -138,7 +138,7 @@ class TestPipeLineFactory(test.NoDBTestCase): def __init__(self, name): self.name = name - class FakeLoader(): + class FakeLoader(object): def get_filter(self, name): return TestPipeLineFactory.FakeFilter(name) diff --git a/nova/tests/unit/fake_network.py b/nova/tests/unit/fake_network.py index 09f54b13d389..847ff783fc96 100644 --- a/nova/tests/unit/fake_network.py +++ b/nova/tests/unit/fake_network.py @@ -50,7 +50,7 @@ class FakeNetworkManager(network_manager.NetworkManager): inherited service cruft and just perform unit tests. """ - class FakeDB: + class FakeDB(object): vifs = [{'id': 0, 'created_at': None, 'updated_at': None, diff --git a/nova/tests/unit/fake_volume.py b/nova/tests/unit/fake_volume.py index 6fbe560162b7..10c16094a2e5 100644 --- a/nova/tests/unit/fake_volume.py +++ b/nova/tests/unit/fake_volume.py @@ -29,7 +29,7 @@ CONF.import_opt('cross_az_attach', 'nova.volume.cinder', group='cinder') -class fake_volume(): +class fake_volume(object): user_uuid = '4a3cd440-b9c2-11e1-afa6-0800200c9a66' instance_uuid = '4a3cd441-b9c2-11e1-afa6-0800200c9a66' @@ -80,7 +80,7 @@ class fake_volume(): self.vol[key] -class fake_snapshot(): +class fake_snapshot(object): user_uuid = '4a3cd440-b9c2-11e1-afa6-0800200c9a66' instance_uuid = '4a3cd441-b9c2-11e1-afa6-0800200c9a66' @@ -119,7 +119,7 @@ class API(object): snapshot_list = [] _instance = None - class Singleton: + class Singleton(object): def __init__(self): self.API = None diff --git a/nova/tests/unit/monkey_patch_example/example_a.py b/nova/tests/unit/monkey_patch_example/example_a.py index 3fdb4dcc0562..3844766ea7e5 100644 --- a/nova/tests/unit/monkey_patch_example/example_a.py +++ b/nova/tests/unit/monkey_patch_example/example_a.py @@ -19,7 +19,7 @@ def example_function_a(): return 'Example function' -class ExampleClassA(): +class ExampleClassA(object): def example_method(self): return 'Example method' diff --git a/nova/tests/unit/monkey_patch_example/example_b.py b/nova/tests/unit/monkey_patch_example/example_b.py index 2515fd2be4b9..52803377fc10 100644 --- a/nova/tests/unit/monkey_patch_example/example_b.py +++ b/nova/tests/unit/monkey_patch_example/example_b.py @@ -20,7 +20,7 @@ def example_function_b(): return 'Example function' -class ExampleClassB(): +class ExampleClassB(object): def example_method(self): return 'Example method' diff --git a/nova/tests/unit/objects/test_fields.py b/nova/tests/unit/objects/test_fields.py index 78cd0d46f731..5cc52ce2a067 100644 --- a/nova/tests/unit/objects/test_fields.py +++ b/nova/tests/unit/objects/test_fields.py @@ -59,7 +59,7 @@ class TestField(test.NoDBTestCase): in_val)) def test_from_primitive(self): - class ObjectLikeThing: + class ObjectLikeThing(object): _context = 'context' for prim_val, out_val in self.from_primitive_values: diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index c80f6d3d32f2..37780adaade6 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -471,7 +471,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.stubs.Set(imagebackend.Image, 'resolve_driver_format', imagebackend.Image._get_driver_format) - class FakeConn(): + class FakeConn(object): def baselineCPU(self, cpu, flag): """Add new libvirt API.""" return """ @@ -718,7 +718,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) - class FakeDev(): + class FakeDev(object): def attach(self): pass @@ -743,7 +743,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.flags(virt_type='xen', group='libvirt') conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) - class FakeDev(): + class FakeDev(object): def attach(self): pass @@ -805,14 +805,14 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.mox.StubOutWithMock(libvirt_driver.LibvirtDriver, '_get_guest_pci_device') - class FakeDev(): + class FakeDev(object): def to_xml(self): pass libvirt_driver.LibvirtDriver._get_guest_pci_device =\ lambda x, y: FakeDev() - class FakeDomain(): + class FakeDomain(object): def detachDeviceFlags(self, xml, flag): pci_devices[0]['hypervisor_name'] = 'marked' pass @@ -849,14 +849,14 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.mox.StubOutWithMock(libvirt_driver.LibvirtDriver, '_get_guest_pci_device') - class FakeDev(): + class FakeDev(object): def to_xml(self): pass libvirt_driver.LibvirtDriver._get_guest_pci_device =\ lambda x, y: FakeDev() - class FakeDomain(): + class FakeDomain(object): def detachDeviceFlags(self, xml, flag): pass @@ -6418,7 +6418,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): {'connection_info': 'dummy', 'mount_device': '/dev/sdb'}]} conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) - class FakeNetworkInfo(): + class FakeNetworkInfo(object): def fixed_ips(self): return ["test_ip_addr"] @@ -6488,7 +6488,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.stubs.Set(conn, '_create_images_and_backing', fake_none) - class FakeNetworkInfo(): + class FakeNetworkInfo(object): def fixed_ips(self): return ["test_ip_addr"] inst_ref = objects.Instance(**self.test_instance) @@ -7042,7 +7042,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): def fake_get_info(instance): return hardware.InstanceInfo(state=power_state.RUNNING) - class FakeLibvirtPciDevice(): + class FakeLibvirtPciDevice(object): def dettach(self): return None @@ -7692,7 +7692,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): None) def test_reboot_different_ids(self): - class FakeLoopingCall: + class FakeLoopingCall(object): def start(self, *a, **k): return self @@ -7732,7 +7732,7 @@ class LibvirtConnTestCase(test.NoDBTestCase): self.assertTrue(self.reboot_create_called) def test_reboot_same_ids(self): - class FakeLoopingCall: + class FakeLoopingCall(object): def start(self, *a, **k): return self @@ -11364,7 +11364,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase): def _test_finish_revert_migration_after_crash(self, backup_made=True, del_inst_failed=False): - class FakeLoopingCall: + class FakeLoopingCall(object): def start(self, *a, **k): return self diff --git a/nova/tests/unit/virt/libvirt/test_firewall.py b/nova/tests/unit/virt/libvirt/test_firewall.py index c71d29c43484..340920a6477d 100644 --- a/nova/tests/unit/virt/libvirt/test_firewall.py +++ b/nova/tests/unit/virt/libvirt/test_firewall.py @@ -44,7 +44,7 @@ _fake_stub_out_get_nw_info = fake_network.stub_out_nw_api_get_instance_nw_info _ipv4_like = fake_network.ipv4_like -class NWFilterFakes: +class NWFilterFakes(object): def __init__(self): self.filters = {} @@ -54,7 +54,7 @@ class NWFilterFakes: raise libvirt.libvirtError('Filter Not Found') def filterDefineXMLMock(self, xml): - class FakeNWFilterInternal: + class FakeNWFilterInternal(object): def __init__(self, parent, name, u, xml): self.name = name self.uuid = u diff --git a/nova/tests/unit/virt/vmwareapi/stubs.py b/nova/tests/unit/virt/vmwareapi/stubs.py index d126b36e0f77..5c8e3f54673f 100644 --- a/nova/tests/unit/virt/vmwareapi/stubs.py +++ b/nova/tests/unit/virt/vmwareapi/stubs.py @@ -104,11 +104,11 @@ def fake_suds_context(calls=None): calls = calls or {} - class fake_factory: + class fake_factory(object): def create(self, name): return mock.NonCallableMagicMock(name=name) - class fake_service: + class fake_service(object): def __getattr__(self, attr_name): if attr_name in calls: return calls[attr_name] @@ -117,7 +117,7 @@ def fake_suds_context(calls=None): calls[attr_name] = mock_call return mock_call - class fake_client: + class fake_client(object): def __init__(self, wdsl_url, **kwargs): self.service = fake_service() self.factory = fake_factory() diff --git a/nova/tests/unit/virt/vmwareapi/test_vmops.py b/nova/tests/unit/virt/vmwareapi/test_vmops.py index 6e251c370db5..9eb393fe04d5 100644 --- a/nova/tests/unit/virt/vmwareapi/test_vmops.py +++ b/nova/tests/unit/virt/vmwareapi/test_vmops.py @@ -40,7 +40,7 @@ from nova.virt.vmwareapi import vm_util from nova.virt.vmwareapi import vmops -class DsPathMatcher: +class DsPathMatcher(object): def __init__(self, expected_ds_path_str): self.expected_ds_path_str = expected_ds_path_str diff --git a/nova/tests/unit/virt/xenapi/test_agent.py b/nova/tests/unit/virt/xenapi/test_agent.py index 5004b381d4aa..fedbcd05997b 100644 --- a/nova/tests/unit/virt/xenapi/test_agent.py +++ b/nova/tests/unit/virt/xenapi/test_agent.py @@ -81,7 +81,7 @@ class AgentImageFlagsTestCase(AgentTestCaseBase): self.assertTrue(agent.should_use_agent(instance)) -class SysMetaKeyTestBase(): +class SysMetaKeyTestBase(object): key = None def _create_agent_with_value(self, value): diff --git a/nova/tests/unit/virt/xenapi/test_vm_utils.py b/nova/tests/unit/virt/xenapi/test_vm_utils.py index 48f7ccb286b1..4cbf41fcc2a5 100644 --- a/nova/tests/unit/virt/xenapi/test_vm_utils.py +++ b/nova/tests/unit/virt/xenapi/test_vm_utils.py @@ -994,7 +994,7 @@ class VDIOtherConfigTestCase(VMUtilsTestBase): def setUp(self): super(VDIOtherConfigTestCase, self).setUp() - class _FakeSession(): + class _FakeSession(object): def call_xenapi(self, operation, *args, **kwargs): # VDI.add_to_other_config -> VDI_add_to_other_config method = getattr(self, operation.replace('.', '_'), None) diff --git a/nova/tests/unit/virt/xenapi/test_xenapi.py b/nova/tests/unit/virt/xenapi/test_xenapi.py index a927244f537f..922ec4341366 100644 --- a/nova/tests/unit/virt/xenapi/test_xenapi.py +++ b/nova/tests/unit/virt/xenapi/test_xenapi.py @@ -1321,7 +1321,7 @@ iface eth0 inet6 static def test_finish_revert_migration(self): instance = self._create_instance() - class VMOpsMock(): + class VMOpsMock(object): def __init__(self): self.finish_revert_migration_called = False diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py index 7aba8f39cf0a..5fb55665286f 100644 --- a/nova/virt/xenapi/fake.py +++ b/nova/virt/xenapi/fake.py @@ -1045,7 +1045,7 @@ class FakeXenAPI(object): # Based upon _Method from xmlrpclib. -class _Dispatcher: +class _Dispatcher(object): def __init__(self, send, name): self.__send = send self.__name = name diff --git a/tox.ini b/tox.ini index a8fd01212f0b..74d7d469a14c 100644 --- a/tox.ini +++ b/tox.ini @@ -68,7 +68,7 @@ commands = python setup.py build_sphinx # E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301 # New from hacking 0.10: H238 -ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405,H238 +ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405 exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools/xenserver* # To get a list of functions that are more complex than 25, set max-complexity # to 25 and run 'tox -epep8'.