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
This commit is contained in:
Sergey Nikitin 2015-01-20 18:05:47 +03:00
parent 07c2929f88
commit a8a87900cf
21 changed files with 39 additions and 38 deletions

View File

@ -96,7 +96,7 @@ class InvalidMetadataPath(Exception):
pass pass
class InstanceMetadata(): class InstanceMetadata(object):
"""Instance metadata.""" """Instance metadata."""
def __init__(self, instance, address=None, content=None, extra_md=None, def __init__(self, instance, address=None, content=None, extra_md=None,

View File

@ -23,7 +23,7 @@ LOG = logging.getLogger(__name__)
RESOURCE_NAMESPACE = 'nova.compute.resources' RESOURCE_NAMESPACE = 'nova.compute.resources'
class ResourceHandler(): class ResourceHandler(object):
def _log_missing_plugins(self, names): def _log_missing_plugins(self, names):
for name in names: for name in names:

View File

@ -39,7 +39,7 @@ from nova import utils
LOG = logging.getLogger('object') LOG = logging.getLogger('object')
class NotSpecifiedSentinel: class NotSpecifiedSentinel(object):
pass pass

View File

@ -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 @abc.abstractmethod
def coerce(self, obj, attr, value): def coerce(self, obj, attr, value):
"""This is called to coerce (if possible) a value on assignment. """This is called to coerce (if possible) a value on assignment.

View File

@ -217,7 +217,7 @@ def stub_out_nw_api(stubs, cls=None, private=None, publics=None):
if not publics: if not publics:
publics = ['1.2.3.4'] publics = ['1.2.3.4']
class Fake: class Fake(object):
def get_instance_nw_info(*args, **kwargs): def get_instance_nw_info(*args, **kwargs):
pass pass

View File

@ -503,7 +503,7 @@ class ResourceTest(test.NoDBTestCase):
'{"barAction": true}') '{"barAction": true}')
def test_get_method_action_method(self): def test_get_method_action_method(self):
class Controller(): class Controller(object):
def action(self, req, pants=None): def action(self, req, pants=None):
return pants return pants

View File

@ -138,7 +138,7 @@ class TestPipeLineFactory(test.NoDBTestCase):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
class FakeLoader(): class FakeLoader(object):
def get_filter(self, name): def get_filter(self, name):
return TestPipeLineFactory.FakeFilter(name) return TestPipeLineFactory.FakeFilter(name)

View File

@ -50,7 +50,7 @@ class FakeNetworkManager(network_manager.NetworkManager):
inherited service cruft and just perform unit tests. inherited service cruft and just perform unit tests.
""" """
class FakeDB: class FakeDB(object):
vifs = [{'id': 0, vifs = [{'id': 0,
'created_at': None, 'created_at': None,
'updated_at': None, 'updated_at': None,

View File

@ -29,7 +29,7 @@ CONF.import_opt('cross_az_attach',
'nova.volume.cinder', group='cinder') 'nova.volume.cinder', group='cinder')
class fake_volume(): class fake_volume(object):
user_uuid = '4a3cd440-b9c2-11e1-afa6-0800200c9a66' user_uuid = '4a3cd440-b9c2-11e1-afa6-0800200c9a66'
instance_uuid = '4a3cd441-b9c2-11e1-afa6-0800200c9a66' instance_uuid = '4a3cd441-b9c2-11e1-afa6-0800200c9a66'
@ -80,7 +80,7 @@ class fake_volume():
self.vol[key] self.vol[key]
class fake_snapshot(): class fake_snapshot(object):
user_uuid = '4a3cd440-b9c2-11e1-afa6-0800200c9a66' user_uuid = '4a3cd440-b9c2-11e1-afa6-0800200c9a66'
instance_uuid = '4a3cd441-b9c2-11e1-afa6-0800200c9a66' instance_uuid = '4a3cd441-b9c2-11e1-afa6-0800200c9a66'
@ -119,7 +119,7 @@ class API(object):
snapshot_list = [] snapshot_list = []
_instance = None _instance = None
class Singleton: class Singleton(object):
def __init__(self): def __init__(self):
self.API = None self.API = None

View File

@ -19,7 +19,7 @@ def example_function_a():
return 'Example function' return 'Example function'
class ExampleClassA(): class ExampleClassA(object):
def example_method(self): def example_method(self):
return 'Example method' return 'Example method'

View File

@ -20,7 +20,7 @@ def example_function_b():
return 'Example function' return 'Example function'
class ExampleClassB(): class ExampleClassB(object):
def example_method(self): def example_method(self):
return 'Example method' return 'Example method'

View File

@ -59,7 +59,7 @@ class TestField(test.NoDBTestCase):
in_val)) in_val))
def test_from_primitive(self): def test_from_primitive(self):
class ObjectLikeThing: class ObjectLikeThing(object):
_context = 'context' _context = 'context'
for prim_val, out_val in self.from_primitive_values: for prim_val, out_val in self.from_primitive_values:

View File

@ -471,7 +471,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.stubs.Set(imagebackend.Image, 'resolve_driver_format', self.stubs.Set(imagebackend.Image, 'resolve_driver_format',
imagebackend.Image._get_driver_format) imagebackend.Image._get_driver_format)
class FakeConn(): class FakeConn(object):
def baselineCPU(self, cpu, flag): def baselineCPU(self, cpu, flag):
"""Add new libvirt API.""" """Add new libvirt API."""
return """<cpu mode='custom' match='exact'> return """<cpu mode='custom' match='exact'>
@ -718,7 +718,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
class FakeDev(): class FakeDev(object):
def attach(self): def attach(self):
pass pass
@ -743,7 +743,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.flags(virt_type='xen', group='libvirt') self.flags(virt_type='xen', group='libvirt')
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True) conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
class FakeDev(): class FakeDev(object):
def attach(self): def attach(self):
pass pass
@ -805,14 +805,14 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.mox.StubOutWithMock(libvirt_driver.LibvirtDriver, self.mox.StubOutWithMock(libvirt_driver.LibvirtDriver,
'_get_guest_pci_device') '_get_guest_pci_device')
class FakeDev(): class FakeDev(object):
def to_xml(self): def to_xml(self):
pass pass
libvirt_driver.LibvirtDriver._get_guest_pci_device =\ libvirt_driver.LibvirtDriver._get_guest_pci_device =\
lambda x, y: FakeDev() lambda x, y: FakeDev()
class FakeDomain(): class FakeDomain(object):
def detachDeviceFlags(self, xml, flag): def detachDeviceFlags(self, xml, flag):
pci_devices[0]['hypervisor_name'] = 'marked' pci_devices[0]['hypervisor_name'] = 'marked'
pass pass
@ -849,14 +849,14 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.mox.StubOutWithMock(libvirt_driver.LibvirtDriver, self.mox.StubOutWithMock(libvirt_driver.LibvirtDriver,
'_get_guest_pci_device') '_get_guest_pci_device')
class FakeDev(): class FakeDev(object):
def to_xml(self): def to_xml(self):
pass pass
libvirt_driver.LibvirtDriver._get_guest_pci_device =\ libvirt_driver.LibvirtDriver._get_guest_pci_device =\
lambda x, y: FakeDev() lambda x, y: FakeDev()
class FakeDomain(): class FakeDomain(object):
def detachDeviceFlags(self, xml, flag): def detachDeviceFlags(self, xml, flag):
pass pass
@ -6418,7 +6418,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
{'connection_info': 'dummy', 'mount_device': '/dev/sdb'}]} {'connection_info': 'dummy', 'mount_device': '/dev/sdb'}]}
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
class FakeNetworkInfo(): class FakeNetworkInfo(object):
def fixed_ips(self): def fixed_ips(self):
return ["test_ip_addr"] return ["test_ip_addr"]
@ -6488,7 +6488,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.stubs.Set(conn, '_create_images_and_backing', fake_none) self.stubs.Set(conn, '_create_images_and_backing', fake_none)
class FakeNetworkInfo(): class FakeNetworkInfo(object):
def fixed_ips(self): def fixed_ips(self):
return ["test_ip_addr"] return ["test_ip_addr"]
inst_ref = objects.Instance(**self.test_instance) inst_ref = objects.Instance(**self.test_instance)
@ -7042,7 +7042,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
def fake_get_info(instance): def fake_get_info(instance):
return hardware.InstanceInfo(state=power_state.RUNNING) return hardware.InstanceInfo(state=power_state.RUNNING)
class FakeLibvirtPciDevice(): class FakeLibvirtPciDevice(object):
def dettach(self): def dettach(self):
return None return None
@ -7692,7 +7692,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
None) None)
def test_reboot_different_ids(self): def test_reboot_different_ids(self):
class FakeLoopingCall: class FakeLoopingCall(object):
def start(self, *a, **k): def start(self, *a, **k):
return self return self
@ -7732,7 +7732,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.assertTrue(self.reboot_create_called) self.assertTrue(self.reboot_create_called)
def test_reboot_same_ids(self): def test_reboot_same_ids(self):
class FakeLoopingCall: class FakeLoopingCall(object):
def start(self, *a, **k): def start(self, *a, **k):
return self return self
@ -11364,7 +11364,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
def _test_finish_revert_migration_after_crash(self, backup_made=True, def _test_finish_revert_migration_after_crash(self, backup_made=True,
del_inst_failed=False): del_inst_failed=False):
class FakeLoopingCall: class FakeLoopingCall(object):
def start(self, *a, **k): def start(self, *a, **k):
return self return self

View File

@ -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 _ipv4_like = fake_network.ipv4_like
class NWFilterFakes: class NWFilterFakes(object):
def __init__(self): def __init__(self):
self.filters = {} self.filters = {}
@ -54,7 +54,7 @@ class NWFilterFakes:
raise libvirt.libvirtError('Filter Not Found') raise libvirt.libvirtError('Filter Not Found')
def filterDefineXMLMock(self, xml): def filterDefineXMLMock(self, xml):
class FakeNWFilterInternal: class FakeNWFilterInternal(object):
def __init__(self, parent, name, u, xml): def __init__(self, parent, name, u, xml):
self.name = name self.name = name
self.uuid = u self.uuid = u

View File

@ -104,11 +104,11 @@ def fake_suds_context(calls=None):
calls = calls or {} calls = calls or {}
class fake_factory: class fake_factory(object):
def create(self, name): def create(self, name):
return mock.NonCallableMagicMock(name=name) return mock.NonCallableMagicMock(name=name)
class fake_service: class fake_service(object):
def __getattr__(self, attr_name): def __getattr__(self, attr_name):
if attr_name in calls: if attr_name in calls:
return calls[attr_name] return calls[attr_name]
@ -117,7 +117,7 @@ def fake_suds_context(calls=None):
calls[attr_name] = mock_call calls[attr_name] = mock_call
return mock_call return mock_call
class fake_client: class fake_client(object):
def __init__(self, wdsl_url, **kwargs): def __init__(self, wdsl_url, **kwargs):
self.service = fake_service() self.service = fake_service()
self.factory = fake_factory() self.factory = fake_factory()

View File

@ -40,7 +40,7 @@ from nova.virt.vmwareapi import vm_util
from nova.virt.vmwareapi import vmops from nova.virt.vmwareapi import vmops
class DsPathMatcher: class DsPathMatcher(object):
def __init__(self, expected_ds_path_str): def __init__(self, expected_ds_path_str):
self.expected_ds_path_str = expected_ds_path_str self.expected_ds_path_str = expected_ds_path_str

View File

@ -81,7 +81,7 @@ class AgentImageFlagsTestCase(AgentTestCaseBase):
self.assertTrue(agent.should_use_agent(instance)) self.assertTrue(agent.should_use_agent(instance))
class SysMetaKeyTestBase(): class SysMetaKeyTestBase(object):
key = None key = None
def _create_agent_with_value(self, value): def _create_agent_with_value(self, value):

View File

@ -994,7 +994,7 @@ class VDIOtherConfigTestCase(VMUtilsTestBase):
def setUp(self): def setUp(self):
super(VDIOtherConfigTestCase, self).setUp() super(VDIOtherConfigTestCase, self).setUp()
class _FakeSession(): class _FakeSession(object):
def call_xenapi(self, operation, *args, **kwargs): def call_xenapi(self, operation, *args, **kwargs):
# VDI.add_to_other_config -> VDI_add_to_other_config # VDI.add_to_other_config -> VDI_add_to_other_config
method = getattr(self, operation.replace('.', '_'), None) method = getattr(self, operation.replace('.', '_'), None)

View File

@ -1321,7 +1321,7 @@ iface eth0 inet6 static
def test_finish_revert_migration(self): def test_finish_revert_migration(self):
instance = self._create_instance() instance = self._create_instance()
class VMOpsMock(): class VMOpsMock(object):
def __init__(self): def __init__(self):
self.finish_revert_migration_called = False self.finish_revert_migration_called = False

View File

@ -1045,7 +1045,7 @@ class FakeXenAPI(object):
# Based upon _Method from xmlrpclib. # Based upon _Method from xmlrpclib.
class _Dispatcher: class _Dispatcher(object):
def __init__(self, send, name): def __init__(self, send, name):
self.__send = send self.__send = send
self.__name = name self.__name = name

View File

@ -68,7 +68,7 @@ commands = python setup.py build_sphinx
# E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301 # E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301
# New from hacking 0.10: H238 # 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* 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 get a list of functions that are more complex than 25, set max-complexity
# to 25 and run 'tox -epep8'. # to 25 and run 'tox -epep8'.