Bump hacking

hacking 3.1.x is too old.

Change-Id: Ic5131276ac1d1a1a959d0a5b16398ae12fae0c18
This commit is contained in:
Takashi Kajinami 2024-01-27 23:20:30 +09:00
parent 5775bcef47
commit b488f42332
27 changed files with 60 additions and 62 deletions

View File

@ -32,7 +32,7 @@ repos:
- id: flake8
name: flake8
additional_dependencies:
- hacking>=3.1.0,<3.2.0
- hacking>=6.1.0,<6.2.0
language: python
entry: flake8
files: '^.*\.py$'

View File

@ -219,7 +219,7 @@ def main():
# Run consumer
print_with_time("Consumer was successfully run.")
while(True):
while True:
messages = pop_zaqar_messages(
zaqarclientwrapper.ZAQARCLIENT, CONF.zaqar.zaqar_queues)
if not messages:

View File

@ -438,7 +438,7 @@ def validate_common_name(access):
common name. The meaning of a string depends on its
interpretation and is limited to 64 characters.
"""
if not(0 < len(access) < 65):
if not (0 < len(access) < 65):
exc_str = _('Invalid CN (common name). Must be 1-64 chars long.')
raise webob.exc.HTTPBadRequest(explanation=exc_str)

View File

@ -267,7 +267,7 @@ class APIVersionRequest(utils.ComparableMixin):
@experimental.setter
def experimental(self, value):
if type(value) != bool:
if not isinstance(value, bool):
msg = _('The experimental property must be a bool value.')
raise exception.InvalidParameterValue(err=msg)
self._experimental = value
@ -275,7 +275,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 not isinstance(method, versioned_method.VersionedMethod):
msg = _('An API version request must be compared '
'to a VersionedMethod object.')
raise exception.InvalidParameterValue(err=msg)

View File

@ -56,7 +56,7 @@ class ShareSnapshotMixin(object):
snapshot = self.share_api.get_snapshot(context, id)
# Snapshot with no instances is filtered out.
if(snapshot.get('status') is None):
if snapshot.get('status') is None:
raise exc.HTTPNotFound()
except exception.NotFound:
raise exc.HTTPNotFound()

View File

@ -142,11 +142,11 @@ class ShareNetworkController(wsgi.Controller, wsgi.AdminActionsMixin):
id,
security_service['id'])
except Exception:
LOG.exception(
"Failed to delete security association of network "
"{net_id} and security service "
"{sec_id}".format(net_id=id,
sec_id=security_service['id']))
msg = ("Failed to delete security association of network "
"{net_id} and security service "
"{sec_id}".format(net_id=id,
sec_id=security_service['id']))
LOG.exception(msg)
db_api.share_network_delete(context, id)

View File

@ -352,11 +352,11 @@ class IpRouteCommand(IpDeviceCommandBase):
'list', 'proto', 'kernel', 'exact', subnet).split('\n')
for subnet_route_line in subnet_route_list_lines:
i = iter(subnet_route_line.split())
while(next(i) != 'dev'):
while next(i) != 'dev':
pass
device = next(i)
try:
while(next(i) != 'src'):
while next(i) != 'src':
pass
src = next(i)
except Exception:

View File

@ -28,7 +28,7 @@ def _operatorOperands(tokenList):
try:
op1 = next(it)
op2 = next(it)
yield(op1, op2)
yield (op1, op2)
except StopIteration:
break

View File

@ -587,8 +587,8 @@ class CephFSDriver(driver.ExecuteMixin, driver.GaneshaMixin,
if share['share_group_id'] is not None:
argdict.update({"group_name": share["share_group_id"]})
LOG.debug("extend_share {id} {size}".format(
id=share['id'], size=new_size))
LOG.debug("extend_share {id} {size}",
{"id": share['id'], "size": new_size})
rados_command(self.rados_client, "fs subvolume resize", argdict)

View File

@ -2032,7 +2032,7 @@ class NFSShare(StorageObject):
access_hosts = set()
try:
access_hosts.remove('-0.0.0.0/0.0.0.0')
except(ValueError, KeyError):
except (ValueError, KeyError):
pass
access_str = ('access=%(access)s' % {'access': ':'.join(

View File

@ -305,7 +305,7 @@ class GaneshaManager(object):
try:
self.execute('mv', tmpf, path)
except exception.ProcessExecutionError as e:
LOG.error('mv temp file ({0}) to {1} failed.'.format(tmpf, path))
LOG.error('mv temp file (%s) to %s failed.', tmpf, path)
self.execute('rm', tmpf)
raise exception.GaneshaCommandFailure(
stdout=e.stdout, stderr=e.stderr, exit_code=e.exit_code,
@ -546,8 +546,8 @@ class GaneshaManager(object):
bytes_read = ioctx.read(object_name, max_size)
if ((len(bytes_read) == max_size) and
(ioctx.read(object_name, 1, offset=max_size))):
LOG.warning("Size of object {0} exceeds '{1}' bytes "
"read".format(object_name, max_size))
LOG.warning("Size of object %s exceeds '%d' bytes "
"read", object_name, max_size)
finally:
ioctx.close()
@ -595,7 +595,7 @@ class GaneshaManager(object):
try:
ioctx.remove_object(object_name)
except rados.ObjectNotFound:
LOG.warning("Object '{0}' was already removed".format(object_name))
LOG.warning("Object '%s' was already removed", object_name)
finally:
ioctx.close()

View File

@ -81,7 +81,7 @@ class GlusterfsShareDriverBase(driver.ShareDriver):
False)
def _setup_via_manager(self, share_mgr, share_mgr_parent=None):
"""Callback for layout's `create_share` and `create_share_from_snapshot`
"""Callback for layout's `create_share`/`create_share_from_snapshot`
:param share_mgr: a {'share': <share>, 'manager': <gmgr>}
dict where <share> is the share created

View File

@ -113,7 +113,7 @@ class RestHelper(object):
result = self.do_call(url, data, 'POST',
calltimeout=constants.LOGIN_SOCKET_TIMEOUT)
if((result['error']['code'] != 0)
if ((result['error']['code'] != 0)
or ("data" not in result)
or (result['data']['deviceid'] is None)):
LOG.error("Login to %s failed, try another.", item_url)
@ -142,7 +142,7 @@ class RestHelper(object):
old_url = self.url
result = self.do_call(url, data, method)
error_code = result['error']['code']
if(error_code == constants.ERROR_CONNECT_TO_SERVER
if (error_code == constants.ERROR_CONNECT_TO_SERVER
or error_code == constants.ERROR_UNAUTHORIZED_TO_SERVER):
LOG.error("Can't open the recent url, re-login.")
deviceid = self.login()

View File

@ -2690,8 +2690,8 @@ class ShareManager(manager.SchedulerDependentManager):
updated_export_locs = updated_replica.get(
'export_locations')
if(updated_export_locs is not None
and isinstance(updated_export_locs, list)):
if updated_export_locs is not None \
and isinstance(updated_export_locs, list):
self.db.export_locations_update(
context, updated_replica['id'],
updated_export_locs)

View File

@ -406,7 +406,7 @@ class TestCase(base_test.BaseTestCase):
try:
f = super(TestCase, self).assertIn
except AttributeError:
self.assertTrue(a in b, *args, **kwargs)
self.assertIn(a, b, *args, **kwargs)
else:
f(a, b, *args, **kwargs)
@ -415,7 +415,7 @@ class TestCase(base_test.BaseTestCase):
try:
f = super(TestCase, self).assertNotIn
except AttributeError:
self.assertFalse(a in b, *args, **kwargs)
self.assertNotIn(a, b, *args, **kwargs)
else:
f(a, b, *args, **kwargs)

View File

@ -166,7 +166,7 @@ class ShareAccessDatabaseAPITestCase(test.TestCase):
share_access_keys_present = True if with_share_access_data else False
actual_access_ids = [r['access_id'] for r in rules]
self.assertTrue(isinstance(actual_access_ids, list))
self.assertIsInstance(actual_access_ids, list)
expected = [access_1['id'], access_2['id']]
self.assertEqual(len(expected), len(actual_access_ids))
for pool in expected:
@ -3649,9 +3649,9 @@ class ShareServerDatabaseAPITestCase(test.TestCase):
self.assertEqual(2, len(servers))
ids = [s['id'] for s in servers]
self.assertTrue(valid['id'] in ids)
self.assertTrue(other['id'] in ids)
self.assertFalse(invalid['id'] in ids)
self.assertIn(valid['id'], ids)
self.assertIn(other['id'], ids)
self.assertNotIn(invalid['id'], ids)
def test_get_all_by_host_and_share_subnet_not_found(self):
self.assertRaises(
@ -5615,8 +5615,7 @@ class ResourceLocksTestCase(test.TestCase):
]
self.assertEqual(order_expected,
[lock['id'] for lock in all_project_locks])
self.assertTrue(lk_5['project_id']
not in [self.project_id, project_id_2])
self.assertNotIn(lk_5['project_id'], [self.project_id, project_id_2])
self.assertIsNone(count)
filtered_locks, count = db_api.resource_lock_get_all(

View File

@ -17,7 +17,6 @@ import ast
import re
from hacking import core
import pycodestyle
"""
@ -104,7 +103,7 @@ class BaseASTChecker(ast.NodeVisitor):
@core.flake8ext
def no_translate_logs(logical_line):
if translated_log.match(logical_line):
yield(0, "M359 Don't translate log messages!")
yield (0, "M359 Don't translate log messages!")
class CheckLoggingFormatArgs(BaseASTChecker):
@ -193,7 +192,7 @@ def check_explicit_underscore_import(logical_line, filename):
custom_underscore_check.match(logical_line)):
UNDERSCORE_IMPORT_FILES.append(filename)
elif string_translation.match(logical_line):
yield(0, "M323: Found use of _() without explicit import of _ !")
yield (0, "M323: Found use of _() without explicit import of _ !")
class CheckForTransAdd(BaseASTChecker):
@ -221,14 +220,14 @@ class CheckForTransAdd(BaseASTChecker):
@core.flake8ext
def check_oslo_namespace_imports(physical_line, logical_line, filename):
if pycodestyle.noqa(physical_line):
def check_oslo_namespace_imports(logical_line, filename, noqa):
if noqa:
return
if re.match(oslo_namespace_imports, logical_line):
msg = ("M333: '%s' must be used instead of '%s'.") % (
logical_line.replace('oslo.', 'oslo_'),
logical_line)
yield(0, msg)
yield (0, msg)
@core.flake8ext
@ -243,7 +242,7 @@ def dict_constructor_with_list_copy(logical_line):
@core.flake8ext
def no_xrange(logical_line):
if assert_no_xrange_re.match(logical_line):
yield(0, "M337: Do not use xrange().")
yield (0, "M337: Do not use xrange().")
@core.flake8ext
@ -251,7 +250,7 @@ def validate_assertTrue(logical_line):
if re.match(assert_True, logical_line):
msg = ("M313: Unit tests should use assertTrue(value) instead"
" of using assertEqual(True, value).")
yield(0, msg)
yield (0, msg)
@core.flake8ext
@ -284,7 +283,7 @@ def no_log_warn_check(logical_line):
"""
msg = ("M338: LOG.warn is deprecated, use LOG.warning.")
if re.match(no_log_warn, logical_line):
yield(0, msg)
yield (0, msg)
@core.flake8ext
@ -295,4 +294,4 @@ def no_third_party_mock(logical_line):
re.match(from_third_party_mock, logical_line)):
msg = ('M339: Unit tests should use the standard library "mock" '
'module, not the third party mock library.')
yield(0, msg)
yield (0, msg)

View File

@ -638,7 +638,7 @@ class HostManagerTestCase(test.TestCase):
},
},
]
self.assertTrue(isinstance(res, list))
self.assertIsInstance(res, list)
self.assertEqual(len(expected), len(res))
for pool in expected:
self.assertIn(pool, res)

View File

@ -144,7 +144,7 @@ class GaneshaConfigTests(test.TestCase):
# whitespace-split expressions to tokens with
# (equality is forced to be treated as token by
# sandwiching in space)
conf = map(lambda l: l.replace("=", " = ").split(), conf)
conf = map(lambda line: line.replace("=", " = ").split(), conf)
# get rid of by-product empty lists (derived from superflouous
# ";"-s that might have crept in due to "sandwiching")
conf = map(lambda x: x, conf)

View File

@ -87,7 +87,7 @@ class GlusterfsShareDriverBaseTestCase(test.TestCase):
if layout_name is not None:
conf.glusterfs_share_layout = layout_name
if has_snap is None:
del(_layout._snapshots_are_supported)
del _layout._snapshots_are_supported
else:
_layout._snapshots_are_supported = has_snap

View File

@ -257,7 +257,7 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
test_args = ('volume', 'list')
def raise_exception(*args, **kwargs):
if(args == test_args):
if args == test_args:
raise exception.GlusterfsException()
self._layout.configuration.glusterfs_servers = [self.glusterfs_server1]
@ -438,8 +438,8 @@ class GlusterfsVolumeMappedLayoutTestCase(test.TestCase):
self._layout._push_gluster_vol(self.glusterfs_target2)
self.assertEqual(1, len(self._layout.gluster_used_vols))
self.assertFalse(
self.glusterfs_target2 in self._layout.gluster_used_vols)
self.assertNotIn(self.glusterfs_target2,
self._layout.gluster_used_vols)
def test_push_gluster_vol_excp(self):
self._layout.gluster_used_vols = set([self.glusterfs_target1])

View File

@ -286,7 +286,7 @@ HNAS_RESULT_tree_job_status_fail = """JOB ID : d933100a-b5f6-11d0-91d9-836896aad
Source files missing : 0
Source files skipped : 801
Skipping details : 104 symlinks, 452 hard links,
47 block special devices, 25 character devices"""
47 block special devices, 25 character devices""" # noqa
HNAS_RESULT_job_completed = """JOB ID : ab4211b8-aac8-11ce-91af-39e0822ea368
Job request

View File

@ -2747,8 +2747,8 @@ class NetAppRestCmodeClientTestCase(test.TestCase):
@ddt.data(True, False)
def test_update_volume_efficiency_attributes(self, status):
response = {
'dedupe': not(status),
'compression': not(status)
'dedupe': not status,
'compression': not status
}
self.mock_object(self.client, 'get_volume_efficiency_status',
mock.Mock(return_value=response))
@ -6089,7 +6089,7 @@ class NetAppRestCmodeClientTestCase(test.TestCase):
def test__create_vlan(self, code):
self.mock_object(self.client, 'send_request',
mock.Mock(side_effect=self._mock_api_error(code)))
if not(code):
if not code:
self.assertRaises(exception.NetAppException,
self.client._create_vlan,
fake.NODE_NAME,
@ -6114,7 +6114,7 @@ class NetAppRestCmodeClientTestCase(test.TestCase):
mock.Mock(return_value=volume))
self.mock_object(self.client, 'send_request',
mock.Mock(side_effect=self._mock_api_error(code)))
if not(code):
if not code:
self.assertRaises(exception.NetAppException,
self.client.delete_fpolicy_event,
fake.SHARE_NAME, 'fake_event')
@ -6129,7 +6129,7 @@ class NetAppRestCmodeClientTestCase(test.TestCase):
mock.Mock(return_value=volume))
self.mock_object(self.client, 'send_request',
mock.Mock(side_effect=self._mock_api_error(code)))
if not(code):
if not code:
self.assertRaises(exception.NetAppException,
self.client.delete_fpolicy_policy,
fake.SHARE_NAME, 'fake_policy')
@ -6545,7 +6545,7 @@ class NetAppRestCmodeClientTestCase(test.TestCase):
netapp_api.api.NaApiError(code=code)]
self.mock_object(self.client, 'send_request',
mock.Mock(side_effect=responses))
if not(code):
if not code:
self.assertRaises(netapp_api.api.NaApiError,
self.client.remove_cifs_share,
fake.SHARE_NAME)

View File

@ -300,7 +300,7 @@ class ServiceInstanceManagerTestCase(test.TestCase):
self.fake_time = 0
def fake_connect(addr):
if not(is_ok and self.fake_time > 1):
if not (is_ok and self.fake_time > 1):
raise service_instance.socket.error
def fake_time():

View File

@ -453,7 +453,7 @@ class ShareInstanceAccessTestCase(test.TestCase):
# Asserts
self.assertIsNone(retval)
self.assertEqual(share_instance_id, call_args[1]['id'])
self.assertTrue(isinstance(access_rules_to_be_on_share, list))
self.assertIsInstance(access_rules_to_be_on_share, list)
self.assertEqual(len(expected_rules_to_be_on_share),
len(access_rules_to_be_on_share))
for pool in expected_rules_to_be_on_share:
@ -661,7 +661,7 @@ class ShareInstanceAccessTestCase(test.TestCase):
self.assertIsNone(retval)
self.assertEqual(instance['id'], call_args[1]['id'])
self.assertTrue(isinstance(access_rules_to_be_on_share, list))
self.assertIsInstance(access_rules_to_be_on_share, list)
self.assertEqual(len(expected_rules_to_be_on_share),
len(access_rules_to_be_on_share))
for pool in expected_rules_to_be_on_share:

View File

@ -6280,7 +6280,7 @@ class ShareManagerTestCase(test.TestCase):
mock.call(self.context, new_instance['id'], with_share_data=True)
])
cancelled = not(status == constants.TASK_STATE_DATA_COPYING_CANCELLED)
cancelled = not (status == constants.TASK_STATE_DATA_COPYING_CANCELLED)
if status != 'other':
helper.cleanup_new_instance.assert_called_once_with(new_instance)
(self.share_manager._reset_read_only_access_rules.

View File

@ -1,4 +1,4 @@
hacking>=3.1.0,<3.2.0 # Apache-2.0
hacking>=6.1.0,<6.2.0 # Apache-2.0
coverage>=5.2.1 # Apache-2.0
ddt>=1.4.1 # MIT