Merge "Support hacking 6.1.0"

This commit is contained in:
Zuul 2024-05-03 19:51:51 +00:00 committed by Gerrit Code Review
commit e9c18c7f94
25 changed files with 125 additions and 120 deletions

View File

@ -217,7 +217,7 @@ class APIVersionRequest(utils.ComparableMixin):
def matches_versioned_method(self, method):
"""Compares this version to that of a versioned method."""
if type(method) != versioned_method.VersionedMethod:
if type(method) is not versioned_method.VersionedMethod:
msg = _('An API version request must be compared '
'to a VersionedMethod object.')
raise exception.InvalidParameterValue(err=msg)

View File

@ -164,7 +164,8 @@ class TestSCSTAdmDriver(tf.TargetDriverFixture):
mock.patch.object(self.target, 'target_driver',
return_value='iscsi'), \
mock.patch.object(volume_utils, 'generate_username',
side_effect=lambda: 'QZJbisGmn9AL954FNF4D'),\
side_effect=
lambda: 'QZJbisGmn9AL954FNF4D'), \
mock.patch.object(volume_utils, 'generate_password',
side_effect=lambda: 'P68eE7u9eFqDGexd28DQ'):
self.assertEqual(expected_result,

View File

@ -788,16 +788,16 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase):
mock.patch.object(self.volume.driver.vg,
'create_lv_snapshot') as mock_create, \
mock.patch.object(self.volume.driver.vg,
'deactivate_lv') as mock_deactive,\
'deactivate_lv') as mock_deactivate, \
mock.patch.object(self.volume.driver.vg,
'activate_lv') as mock_active:
'activate_lv') as mock_activate:
self.volume.driver.revert_to_snapshot(self.context,
fake_volume,
fake_snapshot)
mock_revert.assert_called_once_with(
self.volume.driver._escape_snapshot(fake_snapshot.name))
mock_deactive.assert_called_once_with(fake_volume.name)
mock_active.assert_called_once_with(fake_volume.name)
mock_deactivate.assert_called_once_with(fake_volume.name)
mock_activate.assert_called_once_with(fake_volume.name)
mock_create.assert_called_once_with(
self.volume.driver._escape_snapshot(fake_snapshot.name),
fake_volume.name, self.configuration.lvm_type)

View File

@ -327,7 +327,7 @@ class TestSeagateClient(test.TestCase):
RequestException("error")]
mock_requests_get.return_value = m
ret = self.client._api_request('/path')
self.assertTrue(type(ret) == etree._Element)
self.assertTrue(type(ret) is etree._Element)
self.assertRaises(stx_exception.ConnectionError,
self.client._api_request,
'/path')

View File

@ -811,10 +811,12 @@ class VolumeMigrationTestCase(base.BaseVolumeTestCase):
old_usage = db.quota_usage_get_all_by_project(elevated, project_id)
with mock.patch.object(self.volume.driver, 'retype') as _retype, \
mock.patch.object(volume_types, 'volume_types_diff') as _diff,\
mock.patch.object(volume_types,
'volume_types_diff') as _diff, \
mock.patch.object(self.volume, 'migrate_volume') as _mig, \
mock.patch.object(db.sqlalchemy.api, 'volume_get') as _vget, \
mock.patch.object(context.RequestContext, 'elevated') as _ctx,\
mock.patch.object(context.RequestContext,
'elevated') as _ctx, \
mock.patch.object(objects.VolumeType, 'get_by_id') as _vtget:
_vget.return_value = volume
_retype.return_value = driver

View File

@ -795,7 +795,7 @@ class ApiClient(object):
if data is None:
return None
if type(klass) == str:
if type(klass) is str:
if klass.startswith('list['):
sub_kls = re.match(r'list\[(.*)\]', klass).group(1)
return [self.__deserialize(sub_data, sub_kls)

View File

@ -1594,7 +1594,7 @@ class NimbleRestAPIExecutor(object):
LOG.debug("Key %(key)s Value %(value)s",
{'key': key, 'value': value})
if key == EXTRA_SPEC_IOPS_LIMIT and value.isdigit():
if type(value) == int or int(value) < MIN_IOPS or (
if type(value) is int or int(value) < MIN_IOPS or (
int(value) > MAX_IOPS):
raise NimbleAPIException(_("%(err)s [%(min)s, %(max)s]") %
{'err': IOPS_ERR_MSG,
@ -2066,7 +2066,7 @@ class NimbleRestAPIExecutor(object):
LOG.debug("Key %(key)s Value %(value)s",
{'key': key, 'value': value})
if key == EXTRA_SPEC_IOPS_LIMIT and value.isdigit():
if type(value) == int or int(value) < MIN_IOPS or (
if type(value) is int or int(value) < MIN_IOPS or (
int(value) > MAX_IOPS):
raise NimbleAPIException(_("Please enter valid IOPS "
"limit in the range ["

View File

@ -53,7 +53,7 @@ class STXFCDriver(cinder.volume.driver.FibreChannelDriver):
self.common = None
self.configuration.append_config_values(san.san_opts)
self.lookup_service = fczm_utils.create_lookup_service()
if type(self) != STXFCDriver:
if type(self) is not STXFCDriver:
return
self.configuration.append_config_values(common.common_opts)

View File

@ -62,7 +62,7 @@ class STXISCSIDriver(cinder.volume.driver.ISCSIDriver):
super(STXISCSIDriver, self).__init__(*args, **kwargs)
self.common = None
self.configuration.append_config_values(san.san_opts)
if type(self) != STXISCSIDriver:
if type(self) is not STXISCSIDriver:
return
self.configuration.append_config_values(common.common_opts)
self.configuration.append_config_values(common.iscsi_opts)
@ -154,7 +154,7 @@ class STXISCSIDriver(cinder.volume.driver.ISCSIDriver):
self.common.client_logout()
def terminate_connection(self, volume, connector, **kwargs):
if type(connector) == dict and 'initiator' in connector:
if type(connector) is dict and 'initiator' in connector:
# multiattach volumes cannot be unmapped here, but will
# be implicity unmapped when the volume is deleted.
if not volume.get('multiattach'):

View File

@ -3079,7 +3079,7 @@ class VolumeManager(manager.CleanableManager,
host)
# Check if the driver retype provided a model update or
# just a retype indication
if type(ret) == tuple:
if type(ret) is tuple:
retyped, retype_model_update = ret
else:
retyped = ret

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.
# Install bounded pep8/pyflakes first, then let flake8 install
hacking>=5.0.0,<5.1.0 # Apache-2.0
hacking>=6.1.0,<6.2.0 # Apache-2.0
flake8-import-order # LGPLv3
flake8-logging-format>=0.6.0 # Apache-2.0

View File

@ -233,7 +233,9 @@ commands =
#
# E251 unexpected spaces around keyword / parameter equals
# reason: no improvement in readability
#
# E275: missing whitespace after keyword
# reason: many failures newly triggered in pycodestyle 2.9.0,
# evaluate if fixing is worthwhile
# E402 module level import not at top of file
# reason: there are numerous places where we import modules
# later for legitimate reasons
@ -249,7 +251,7 @@ commands =
# reason: no real benefit
# G200 Logging statements should not include the exception
# reason: Many existing cases of this that may be legitimate
ignore = E251,E402,W503,W504,H101,G200
ignore = E251,E275,E402,W503,W504,H101,G200
# H904 Delay string interpolations at logging calls.
enable-extensions = H106,H203,H904
exclude = .git,.venv,.tox,dist,tools,doc/ext,*egg,build