Bump hacking to 7.0.0 and fix linting issues

Change-Id: Ic052b52675debb4c3169d84ccd68a01f2d0ce0d8
This commit is contained in:
Seunghun Lee 2024-02-21 12:07:29 +00:00
parent 7490a7fe7f
commit 85a753b136
14 changed files with 53 additions and 54 deletions

View File

@ -8,6 +8,6 @@ Blazar Style Commandments
Blazar Specific Commandments
----------------------------
- [Bl301] Validate that logs are not translated.
- [Bl302] Use LOG.warning() rather than LOG.warn().
- [B301] Validate that logs are not translated.
- [B302] Use LOG.warning() rather than LOG.warn().
- [H904] Delay string interpolations at logging calls.

View File

@ -68,7 +68,7 @@ class V2Controller(rest.RestController):
self._routes.update(ext.obj.extra_routes)
extensions.append(ext.obj.name)
LOG.debug("Loaded extensions: {0}".format(extensions))
LOG.debug("Loaded extensions: %s", extensions)
@pecan.expose()
def _route(self, args):

View File

@ -109,7 +109,7 @@ class ParsableErrorMiddleware(object):
try:
(exc_name, exc_value) = faultstring.split(' ', 1)
except (ValueError, AttributeError):
LOG.warning('Incorrect Remote error {0}'.format(faultstring))
LOG.warning('Incorrect Remote error %s', faultstring)
else:
cls = getattr(manager_exceptions, exc_name,
getattr(exceptions, exc_name, None))

View File

@ -68,38 +68,38 @@ def upgrade():
# PENDING Lease
pending_query = get_query('UNDONE', 'UNDONE')
for l in pending_query:
for leases in pending_query:
op.execute(
lease.update().values(status='PENDING').
where(lease.c.id == l[0]))
stable_lease_id.append(l[0])
where(lease.c.id == leases[0]))
stable_lease_id.append(leases[0])
# ACTIVE Lease
active_query = get_query('DONE', 'UNDONE')
for l in active_query:
for leases in active_query:
op.execute(
lease.update().values(status='ACTIVE').
where(lease.c.id == l[0]))
stable_lease_id.append(l[0])
where(lease.c.id == leases[0]))
stable_lease_id.append(leases[0])
# TERMINATED Lease
terminated_query = get_query('DONE', 'DONE')
for l in terminated_query:
for leases in terminated_query:
op.execute(
lease.update().values(status='TERMINATED').
where(lease.c.id == l[0]))
stable_lease_id.append(l[0])
where(lease.c.id == leases[0]))
stable_lease_id.append(leases[0])
# ERROR Lease
all_query = sess.query(lease.c.id)
for l in all_query:
if l[0] not in stable_lease_id:
for leases in all_query:
if leases[0] not in stable_lease_id:
op.execute(
lease.update().values(status='ERROR').
where(lease.c.id == l[0]))
where(lease.c.id == leases[0]))
sess.close()

View File

@ -44,7 +44,7 @@ class UsageEnforcement:
if filter_name in filters.all_filters:
self.enabled_filters.add(_filter(conf=CONF))
else:
LOG.error("{} not in filters module.".format(filter_name))
LOG.error("%s not in filters module.", filter_name)
self.enabled_filters = list(self.enabled_filters)

View File

@ -31,7 +31,7 @@ _log_translation_hint = re.compile(
@core.flake8ext
def no_translate_logs(logical_line):
"""Bl301 - Don't translate logs.
"""B301 - Don't translate logs.
Check for 'LOG.*(_('
@ -46,14 +46,14 @@ def no_translate_logs(logical_line):
message describe the check validation failure.
"""
if _log_translation_hint.match(logical_line):
yield (0, "Bl301: Log messages should not be translated!")
yield (0, "B301: Log messages should not be translated!")
@core.flake8ext
def no_log_warn(logical_line):
"""Bl302 - Use LOG.warning() rather than LOG.warn()
"""B302 - Use LOG.warning() rather than LOG.warn()
https://bugs.launchpad.net/tempest/+bug/1508442
"""
if logical_line.startswith('LOG.warn('):
yield(0, 'Bl302 Use LOG.warning() rather than LOG.warn()')
yield (0, 'B302 Use LOG.warning() rather than LOG.warn()')

View File

@ -110,9 +110,9 @@ class ManagerService(service_utils.RPCServer):
try:
plugin_obj = ext.plugin()
except Exception as e:
LOG.warning("Could not load {0} plugin "
"for resource type {1} '{2}'".format(
ext.name, ext.plugin.resource_type, e))
LOG.warning("Could not load %s plugin "
"for resource type %s '%s'",
ext.name, ext.plugin.resource_type, e)
else:
if plugin_obj.resource_type in plugins:
msg = ("You have provided several plugins for "
@ -179,7 +179,7 @@ class ManagerService(service_utils.RPCServer):
event_id)
def _select_for_execution(self, events):
"""Orders the events such that they can be safely executed concurrently.
"""Orders the events such that they can be safely executed concurrently
Events are selected to be executed concurrently if they are of the same
type, while keeping strict time ordering and the following priority of

View File

@ -46,7 +46,7 @@ def list_opts():
blazar.manager.service.manager_opts)),
('enforcement', itertools.chain(
blazar.enforcement.filters.external_service_filter
.ExternalServiceFilter.enforcement_opts,
.ExternalServiceFilter.enforcement_opts,
blazar.enforcement.filters.max_lease_duration_filter.MaxLeaseDurationFilter.enforcement_opts, # noqa
blazar.enforcement.enforcement.enforcement_opts)),
('notifications', blazar.notification.notifier.notification_opts),

View File

@ -104,9 +104,8 @@ class FloatingIpPlugin(base.BasePlugin):
for fip_id in fip_ids_to_add:
try:
fip = db_api.floatingip_get(fip_id)
LOG.debug(
'Creating floating IP {} for reservation {}'.format(
fip['floating_ip_address'], reservation_id))
LOG.debug('Creating floating IP %s for reservation %s',
fip['floating_ip_address'], reservation_id)
fip_pool.create_reserved_floatingip(
fip['subnet_id'], fip['floating_ip_address'],
ctx.project_id, reservation_id)
@ -118,15 +117,15 @@ class FloatingIpPlugin(base.BasePlugin):
raise manager_ex.NeutronClientError(err_msg)
for fip_id in fip_ids_to_add:
LOG.debug('Adding floating IP {} to reservation {}'.format(
fip_id, reservation_id))
LOG.debug('Adding floating IP %s to reservation %s',
fip_id, reservation_id)
db_api.fip_allocation_create({
'floatingip_id': fip_id,
'reservation_id': reservation_id})
for allocation in allocs_to_remove:
LOG.debug('Removing floating IP {} from reservation {}'.format(
allocation['floatingip_id'], reservation_id))
LOG.debug('Removing floating IP %s from reservation %s',
allocation['floatingip_id'], reservation_id)
db_api.fip_allocation_destroy(allocation['id'])
def _allocations_to_remove(self, dates_before, dates_after, allocs,

View File

@ -91,8 +91,8 @@ class TestIncorrectHostFromRPC(api.APITest):
self.assertEqual(400, response.status_int)
self.assertEqual('application/json', response.content_type)
self.assertEqual(expected["error_name"], response.json["error_name"])
self.assertTrue(expected["error_message"]
in response.json["error_message"])
self.assertIn(expected["error_message"],
response.json["error_message"])
self.assertEqual(expected["error_code"], response.json["error_code"])
@ -235,8 +235,8 @@ class TestCreateHost(api.APITest):
self.assertEqual(400, response.status_int)
self.assertEqual('application/json', response.content_type)
self.assertEqual(expected["error_name"], response.json["error_name"])
self.assertTrue(expected["error_message"]
in response.json["error_message"])
self.assertIn(expected["error_message"],
response.json["error_message"])
self.assertEqual(expected["error_code"], response.json["error_code"])
def test_create_with_empty_body(self):
@ -387,8 +387,8 @@ class TestDeleteHost(api.APITest):
self.assertEqual(404, response.status_int)
self.assertEqual('application/json', response.content_type)
self.assertEqual(expected["error_name"], response.json["error_name"])
self.assertTrue(expected["error_message"]
in response.json["error_message"])
self.assertIn(expected["error_message"],
response.json["error_message"])
self.assertEqual(expected["error_code"], response.json["error_code"])
def test_rpc_exception_delete(self):

View File

@ -150,8 +150,8 @@ class TestShowLease(api.APITest):
self.assertEqual(404, response.status_int)
self.assertEqual('application/json', response.content_type)
self.assertEqual(expected["error_name"], response.json["error_name"])
self.assertTrue(expected["error_message"]
in response.json["error_message"])
self.assertIn(expected["error_message"],
response.json["error_message"])
self.assertEqual(expected["error_code"], response.json["error_code"])
def test_rpc_exception_get(self):
@ -202,8 +202,8 @@ class TestCreateLease(api.APITest):
self.assertEqual(400, response.status_int)
self.assertEqual('application/json', response.content_type)
self.assertEqual(expected["error_name"], response.json["error_name"])
self.assertTrue(expected["error_message"]
in response.json["error_message"])
self.assertIn(expected["error_message"],
response.json["error_message"])
self.assertEqual(expected["error_code"], response.json["error_code"])
def test_create_with_empty_body(self):
@ -307,8 +307,8 @@ class TestUpdateLease(api.APITest):
self.assertEqual(404, response.status_int)
self.assertEqual('application/json', response.content_type)
self.assertEqual(expected["error_name"], response.json["error_name"])
self.assertTrue(expected["error_message"]
in response.json["error_message"])
self.assertIn(expected["error_message"],
response.json["error_message"])
self.assertEqual(expected["error_code"], response.json["error_code"])
def test_rpc_exception_update(self):
@ -357,8 +357,8 @@ class TestDeleteLease(api.APITest):
self.assertEqual(404, response.status_int)
self.assertEqual('application/json', response.content_type)
self.assertEqual(expected["error_name"], response.json["error_name"])
self.assertTrue(expected["error_message"]
in response.json["error_message"])
self.assertIn(expected["error_message"],
response.json["error_message"])
self.assertEqual(expected["error_code"], response.json["error_code"])
def test_rpc_exception_delete(self):

View File

@ -436,8 +436,8 @@ class BaseWalkMigrationTestCase(BaseMigrationTestCase):
connection.close()
del(self.engines[database])
del(self.test_databases[database])
del self.engines[database]
del self.test_databases[database]
def _test_postgresql_opportunistically(self):
# Test postgresql database migration walk
@ -456,8 +456,8 @@ class BaseWalkMigrationTestCase(BaseMigrationTestCase):
# build a fully populated postgresql database with all the tables
self._reset_database(database)
self._walk_versions(engine, self.snake_walk, self.downgrade)
del(self.engines[database])
del(self.test_databases[database])
del self.engines[database]
del self.test_databases[database]
def _alembic_command(self, alembic_command, engine, *args, **kwargs):
"""Alembic command redefine reasons

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking>=3.0.1,<3.1.0 # Apache-2.0
hacking>=7.0.0,<7.1.0 # Apache-2.0
ddt>=1.0.1 # MIT
fixtures>=3.0.0 # Apache-2.0/BSD

View File

@ -75,8 +75,8 @@ max-complexity=23
[flake8:local-plugins]
extension =
Bl301 = checks:no_translate_logs
Bl302 = checks:no_log_warn
B301 = checks:no_translate_logs
B302 = checks:no_log_warn
paths = ./blazar/hacking
[testenv:pylint]