From: Anton Arefiev Date: Thu, 2 Apr 2015 16:12:52 +0000 (+0300) Subject: Enable H238 hacking rule X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f17f476a877b1c1d079b5e787d0fc04d35acd60b;p=openstack-build%2Fcinder-build.git Enable H238 hacking rule Hacking 0.10 introduces new hacking rule H238 - old style classes are deprecated (they are converted to new style classes - inherit from `object`). In order to avoid any unwanted side effects all classes should be declared using new style. See reference on the differences: https://www.python.org/download/releases/2.2.3/descrintro/ Change-Id: Iec5620e8f9da2d051a3754391eab4e75faf644e0 --- diff --git a/cinder/backup/drivers/swift.py b/cinder/backup/drivers/swift.py index 1c302afc0..7d0ba656c 100644 --- a/cinder/backup/drivers/swift.py +++ b/cinder/backup/drivers/swift.py @@ -167,7 +167,7 @@ class SwiftBackupDriver(chunkeddriver.ChunkedBackupDriver): preauthtoken=self.context.auth_token, starting_backoff=self.swift_backoff) - class SwiftObjectWriter: + class SwiftObjectWriter(object): def __init__(self, container, object_name, conn): self.container = container self.object_name = object_name @@ -203,7 +203,7 @@ class SwiftBackupDriver(chunkeddriver.ChunkedBackupDriver): raise exception.InvalidBackup(reason=err) return md5 - class SwiftObjectReader: + class SwiftObjectReader(object): def __init__(self, container, object_name, conn): self.container = container self.object_name = object_name diff --git a/cinder/tests/api/openstack/test_wsgi.py b/cinder/tests/api/openstack/test_wsgi.py index 67e57e717..16ccbd718 100644 --- a/cinder/tests/api/openstack/test_wsgi.py +++ b/cinder/tests/api/openstack/test_wsgi.py @@ -400,7 +400,7 @@ class ResourceTest(test.TestCase): '{"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/cinder/tests/monkey_patch_example/example_a.py b/cinder/tests/monkey_patch_example/example_a.py index 3fdb4dcc0..3844766ea 100644 --- a/cinder/tests/monkey_patch_example/example_a.py +++ b/cinder/tests/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/cinder/tests/monkey_patch_example/example_b.py b/cinder/tests/monkey_patch_example/example_b.py index 2515fd2be..52803377f 100644 --- a/cinder/tests/monkey_patch_example/example_b.py +++ b/cinder/tests/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/cinder/tests/test_backup_tsm.py b/cinder/tests/test_backup_tsm.py index 035fa1f00..054c977a1 100644 --- a/cinder/tests/test_backup_tsm.py +++ b/cinder/tests/test_backup_tsm.py @@ -37,7 +37,7 @@ SIM = None VOLUME_PATH = '/dev/null' -class TSMBackupSimulator: +class TSMBackupSimulator(object): """Simulates TSM dsmc command. The simulator simulates the execution of the 'dsmc' command. diff --git a/cinder/tests/test_emc_vmax.py b/cinder/tests/test_emc_vmax.py index d390ed4ff..11b86a638 100644 --- a/cinder/tests/test_emc_vmax.py +++ b/cinder/tests/test_emc_vmax.py @@ -96,7 +96,7 @@ class SE_ReplicationSettingData(dict): self.DesiredCopyMethodology = 0 -class Fake_CIMProperty(): +class Fake_CIMProperty(object): def fake_getCIMProperty(self): cimproperty = Fake_CIMProperty() @@ -144,7 +144,7 @@ class Fake_CIMProperty(): return cimproperty -class Fake_CIM_TierPolicyServiceCapabilities(): +class Fake_CIM_TierPolicyServiceCapabilities(object): def fake_getpolicyinstance(self): classinstance = Fake_CIM_TierPolicyServiceCapabilities() @@ -169,7 +169,7 @@ class FakeCIMInstanceName(dict): return instancename -class FakeDB(): +class FakeDB(object): def volume_update(self, context, volume_id, model_update): pass @@ -200,7 +200,7 @@ class FakeDB(): return snapshots -class EMCVMAXCommonData(): +class EMCVMAXCommonData(object): wwpn1 = "123456789012345" wwpn2 = "123456789054321" connector = {'ip': '10.0.0.2', @@ -433,12 +433,12 @@ class EMCVMAXCommonData(): 'isV3': True} -class FakeLookupService(): +class FakeLookupService(object): def get_device_mapping_from_network(self, initiator_wwns, target_wwns): return EMCVMAXCommonData.device_map -class FakeEcomConnection(): +class FakeEcomConnection(object): def __init__(self, *args, **kwargs): self.data = EMCVMAXCommonData() diff --git a/cinder/tests/test_emc_vnxdirect.py b/cinder/tests/test_emc_vnxdirect.py index e1bd14a13..24b9349d6 100644 --- a/cinder/tests/test_emc_vnxdirect.py +++ b/cinder/tests/test_emc_vnxdirect.py @@ -33,7 +33,7 @@ FAKE_ERROR_RETURN = ("FAKE ERROR", 255) VERSION = emc_vnx_cli.EMCVnxCliBase.VERSION -class EMCVNXCLIDriverTestData(): +class EMCVNXCLIDriverTestData(object): test_volume = { 'name': 'vol1', @@ -3666,7 +3666,7 @@ class EMCVNXCLIDriverFCTestCase(DriverTestCaseBase): fake_cli.assert_has_calls(expect_cmd) -class EMCVNXCLIToggleSPTestData(): +class EMCVNXCLIToggleSPTestData(object): def FAKE_COMMAND_PREFIX(self, sp_address): return ('/opt/Navisphere/bin/naviseccli', '-address', sp_address, '-user', 'sysadmin', '-password', 'sysadmin', diff --git a/cinder/tests/test_emc_xtremio.py b/cinder/tests/test_emc_xtremio.py index a7e90db84..9b28a6b67 100644 --- a/cinder/tests/test_emc_xtremio.py +++ b/cinder/tests/test_emc_xtremio.py @@ -166,7 +166,7 @@ class D(dict): return dict.update(self, *args, **kwargs) -class CommonData(): +class CommonData(object): connector = {'ip': '10.0.0.2', 'initiator': 'iqn.1993-08.org.debian:01:222', 'wwpns': ["123456789012345", "123456789054321"], diff --git a/cinder/tests/test_hds.py b/cinder/tests/test_hds.py index 65a2bf788..361cc0f7b 100644 --- a/cinder/tests/test_hds.py +++ b/cinder/tests/test_hds.py @@ -65,7 +65,7 @@ CONF = """ """ -class SimulatedHusBackend: +class SimulatedHusBackend(object): """Simulation Back end. Talks to HUS.""" alloc_lun = [] # allocated LUs diff --git a/cinder/tests/test_hp3par.py b/cinder/tests/test_hp3par.py index d2405facf..a11d96814 100644 --- a/cinder/tests/test_hp3par.py +++ b/cinder/tests/test_hp3par.py @@ -3030,7 +3030,7 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase): def test_initialize_connection_with_lookup_single_nsp(self, mock_lookup): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client - class fake_lookup_object: + class fake_lookup_object(object): def get_device_mapping_from_network(self, connector, target_wwns): fake_map = { 'FAB_1': { @@ -3185,7 +3185,7 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase): def test_terminate_connection_with_lookup(self, mock_lookup): # setup_mock_client drive with default configuration # and return the mock HTTP 3PAR client - class fake_lookup_object: + class fake_lookup_object(object): def get_device_mapping_from_network(self, connector, target_wwns): fake_map = { 'FAB_1': { diff --git a/cinder/tests/test_hplefthand.py b/cinder/tests/test_hplefthand.py index 3a7b8a996..394581ad3 100644 --- a/cinder/tests/test_hplefthand.py +++ b/cinder/tests/test_hplefthand.py @@ -37,7 +37,7 @@ FILTER_FUNCTION = \ "capabilities.total_volumes < 400 && capabilities.capacity_utilization" -class HPLeftHandBaseDriver(): +class HPLeftHandBaseDriver(object): cluster_id = 1 diff --git a/cinder/tests/test_ibm_flashsystem.py b/cinder/tests/test_ibm_flashsystem.py index eaae98df1..929e101c3 100644 --- a/cinder/tests/test_ibm_flashsystem.py +++ b/cinder/tests/test_ibm_flashsystem.py @@ -41,7 +41,7 @@ from cinder.volume import volume_types LOG = logging.getLogger(__name__) -class FlashSystemManagementSimulator: +class FlashSystemManagementSimulator(object): def __init__(self): # Default protocol is FC self._protocol = 'FC' diff --git a/cinder/tests/test_openvstorage.py b/cinder/tests/test_openvstorage.py index 2893d38ca..fce3116d4 100644 --- a/cinder/tests/test_openvstorage.py +++ b/cinder/tests/test_openvstorage.py @@ -54,7 +54,7 @@ MOCK_image_id = '9999' CALLED = {} -class MockVDiskController(): +class MockVDiskController(object): def create_volume(self, location, size): CALLED['create_volume'] = {'location': location, 'size': size} @@ -84,20 +84,20 @@ class MockVDiskController(): 'diskguid': diskguid} -class MockStorageRouter(): +class MockStorageRouter(object): name = MOCK_hostname -class MockStorageDriver(): +class MockStorageDriver(object): storagerouter = MockStorageRouter() mountpoint = MOCK_mountpoint -class MockVPool(): +class MockVPool(object): storagedrivers = [MockStorageDriver()] -class MockVDisk(): +class MockVDisk(object): vpool = MockVPool() cinder_id = None snapshots = [] @@ -121,7 +121,7 @@ class MockVDisk(): pass -class MockPMachine(): +class MockPMachine(object): guid = MOCK_pmachine_guid storagerouters = [MockStorageRouter()] @@ -129,13 +129,13 @@ class MockPMachine(): pass -class MockVPoolList(): +class MockVPoolList(object): def get_vpool_by_name(self, name): return MockVPool() -class MockVDiskList(): +class MockVDiskList(object): def __init__(self, vdisks = None): self.vdisks = vdisks @@ -146,13 +146,13 @@ class MockVDiskList(): return self.vdisks -class MockPMachineList(): +class MockPMachineList(object): def get_pmachines(self): return [MockPMachine()] -class MOCK_log(): +class MOCK_log(object): def debug(self, *args, **kwargs): pass @@ -167,21 +167,21 @@ class MOCK_log(): pass -class MOCK_Context(): +class MOCK_Context(object): pass -class MOCK_ImageService(): +class MOCK_ImageService(object): pass -class MOCK_ImageUtils(): +class MOCK_ImageUtils(object): def fetch_to_raw(self, context, image_service, image_id, destination_path, block_size, size, run_as_root=False): CALLED['ImageUtils_fetch_to_raw'] = (destination_path, size) -class MOCK_volume(): +class MOCK_volume(object): host = MOCK_hostname size = MOCK_volume_size volume_type_id = MOCK_volume_type_id @@ -205,31 +205,31 @@ class MOCK_volume(): return getattr(self, attribute) -class MOCK_snapshot(): +class MOCK_snapshot(object): volume = MOCK_volume() display_name = MOCK_snapshot_display_name id = MOCK_snapshot_id # Fake Modules -class vdiskhybrid(): +class vdiskhybrid(object): VDisk = MockVDisk -class pmachinelist(): +class pmachinelist(object): PMachineList = MockPMachineList() -class vdisklist(): +class vdisklist(object): def __init__(self, vdisks): self.VDiskList = MockVDiskList(vdisks) -class vpoollist(): +class vpoollist(object): VPoolList = MockVPoolList() -class vdisklib(): +class vdisklib(object): VDiskController = MockVDiskController() diff --git a/cinder/tests/test_sheepdog.py b/cinder/tests/test_sheepdog.py index 70fa065bb..a171b18d4 100644 --- a/cinder/tests/test_sheepdog.py +++ b/cinder/tests/test_sheepdog.py @@ -50,7 +50,7 @@ Epoch Time Version """ -class FakeImageService: +class FakeImageService(object): def download(self, context, image_id, path): pass @@ -107,7 +107,7 @@ class SheepdogTestCase(test.TestCase): def test_copy_image_to_volume(self): @contextlib.contextmanager def fake_temp_file(): - class FakeTmp: + class FakeTmp(object): def __init__(self, name): self.name = name yield FakeTmp('test').name diff --git a/cinder/tests/test_storwize_svc.py b/cinder/tests/test_storwize_svc.py index 4c00b38ab..4312ee5aa 100644 --- a/cinder/tests/test_storwize_svc.py +++ b/cinder/tests/test_storwize_svc.py @@ -45,7 +45,7 @@ from cinder.volume import volume_types LOG = logging.getLogger(__name__) -class StorwizeSVCManagementSimulator: +class StorwizeSVCManagementSimulator(object): def __init__(self, pool_name): self._flags = {'storwize_svc_volpool_name': pool_name} self._volumes_list = {} diff --git a/cinder/tests/test_utils.py b/cinder/tests/test_utils.py index 21ea0c9c3..ef71eed11 100644 --- a/cinder/tests/test_utils.py +++ b/cinder/tests/test_utils.py @@ -485,8 +485,7 @@ class GenericUtilsTestCase(test.TestCase): @mock.patch('os.stat') def test_get_file_mode(self, mock_stat): - - class stat_result: + class stat_result(object): st_mode = 0o777 st_gid = 33333 @@ -499,7 +498,7 @@ class GenericUtilsTestCase(test.TestCase): @mock.patch('os.stat') def test_get_file_gid(self, mock_stat): - class stat_result: + class stat_result(object): st_mode = 0o777 st_gid = 33333 @@ -654,7 +653,7 @@ class GetBlkdevMajorMinorTestCase(test.TestCase): @mock.patch('os.stat') def test_get_file_size(self, mock_stat): - class stat_result: + class stat_result(object): st_mode = 0o777 st_size = 1074253824 @@ -667,7 +666,7 @@ class GetBlkdevMajorMinorTestCase(test.TestCase): @mock.patch('os.stat') def test_get_blkdev_major_minor(self, mock_stat): - class stat_result: + class stat_result(object): st_mode = 0o60660 st_rdev = os.makedev(253, 7) @@ -688,14 +687,14 @@ class GetBlkdevMajorMinorTestCase(test.TestCase): test_file = '/tmp/file' test_disk = '/dev/made_up_disk' - class stat_result_file: + class stat_result_file(object): st_mode = 0o660 - class stat_result_partition: + class stat_result_partition(object): st_mode = 0o60660 st_rdev = os.makedev(8, 65) - class stat_result_disk: + class stat_result_disk(object): st_mode = 0o60660 st_rdev = os.makedev(8, 64) diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index fc511040e..11f5d1d37 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -83,7 +83,7 @@ fake_opt = [ FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa' -class FakeImageService: +class FakeImageService(object): def __init__(self, db_driver=None, image_service=None): pass diff --git a/cinder/volume/drivers/hds/hus_backend.py b/cinder/volume/drivers/hds/hus_backend.py index b29026edf..3252df1e1 100644 --- a/cinder/volume/drivers/hds/hus_backend.py +++ b/cinder/volume/drivers/hds/hus_backend.py @@ -26,7 +26,7 @@ from cinder import utils LOG = logging.getLogger("cinder.volume.driver") -class HusBackend: +class HusBackend(object): """Back end. Talks to HUS.""" def get_version(self, cmd, ver, ip0, ip1, user, pw): out, err = utils.execute(cmd, diff --git a/cinder/volume/drivers/nimble.py b/cinder/volume/drivers/nimble.py index 18ce0103e..92acfd397 100644 --- a/cinder/volume/drivers/nimble.py +++ b/cinder/volume/drivers/nimble.py @@ -400,7 +400,7 @@ def _connection_checker(func): return inner_connection_checker -class NimbleAPIExecutor: +class NimbleAPIExecutor(object): """Makes Nimble API calls.""" diff --git a/cinder/volume/drivers/srb.py b/cinder/volume/drivers/srb.py index 85cc4979a..09f18b32d 100644 --- a/cinder/volume/drivers/srb.py +++ b/cinder/volume/drivers/srb.py @@ -59,7 +59,7 @@ ACCEPTED_REST_SERVER = re.compile(r'^http://' '(:\d+)?/[a-zA-Z0-9\-_\/]*$') -class retry: +class retry(object): SLEEP_NONE = 'none' SLEEP_DOUBLE = 'double' SLEEP_INCREMENT = 'increment' diff --git a/cinder/volume/drivers/vmware/vmdk.py b/cinder/volume/drivers/vmware/vmdk.py index 84cab5308..60225d04b 100644 --- a/cinder/volume/drivers/vmware/vmdk.py +++ b/cinder/volume/drivers/vmware/vmdk.py @@ -150,7 +150,7 @@ def _get_volume_type_extra_spec(type_id, spec_key, possible_values=None, LOG.debug("Invalid spec value: %s specified.", spec_value) -class ImageDiskType: +class ImageDiskType(object): """Supported disk types in images.""" PREALLOCATED = "preallocated" diff --git a/tox.ini b/tox.ini index 6a991857d..3060c8ad8 100644 --- a/tox.ini +++ b/tox.ini @@ -62,11 +62,10 @@ commands = python setup.py build_sphinx # Due to the upgrade to hacking 0.10.0 the following checking are # ignored on purpose for the moment and should be cleaned up and re-enabled. # -# H238 old style class declaration, use new style (inherit from `object`) # H105 Don't use author tags # -ignore = E251,H405,H238,H105 +ignore = E251,H405,H105 exclude = .git,.venv,.tox,dist,tools,doc,common,*egg,build max-complexity=30