trivial: Enable flake8-logging-format (G) rules
Change-Id: Iabc94a0fd40903dc2a81bf62aea8460f20a7e0e4 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -264,7 +264,7 @@ def main(opts, run):
|
||||
if dump_stack_trace:
|
||||
_logger.error(traceback.format_exc(e))
|
||||
else:
|
||||
_logger.error('Exception raised: ' + str(e))
|
||||
_logger.error('Exception raised: %s', e)
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
@@ -272,7 +272,10 @@ class ListQuota(command.Lister):
|
||||
sdk_exceptions.NotFoundException,
|
||||
) as exc:
|
||||
# Project not found, move on to next one
|
||||
LOG.warning(f"Project {project_id} not found: {exc}")
|
||||
LOG.warning(
|
||||
'Project %(project_id)s not found: %(exc)s',
|
||||
{'project_id': project_id, 'exc': exc},
|
||||
)
|
||||
continue
|
||||
|
||||
project_result = _xform_get_quota(
|
||||
@@ -334,7 +337,10 @@ class ListQuota(command.Lister):
|
||||
sdk_exceptions.NotFoundException,
|
||||
) as exc:
|
||||
# Project not found, move on to next one
|
||||
LOG.warning(f"Project {project_id} not found: {exc}")
|
||||
LOG.warning(
|
||||
'Project %(project_id)s not found: %(exc)s',
|
||||
{'project_id': project_id, 'exc': exc},
|
||||
)
|
||||
continue
|
||||
|
||||
project_result = _xform_get_quota(
|
||||
@@ -389,7 +395,10 @@ class ListQuota(command.Lister):
|
||||
sdk_exceptions.ForbiddenException,
|
||||
) as exc:
|
||||
# Project not found, move on to next one
|
||||
LOG.warning(f"Project {project_id} not found: {exc}")
|
||||
LOG.warning(
|
||||
'Project %(project_id)s not found: %(exc)s',
|
||||
{'project_id': project_id, 'exc': exc},
|
||||
)
|
||||
continue
|
||||
|
||||
project_result = _xform_get_quota(
|
||||
|
||||
@@ -5018,7 +5018,7 @@ class SshServer(command.Command):
|
||||
)
|
||||
|
||||
cmd = ' '.join(['ssh', ip_address] + args)
|
||||
LOG.debug(f"ssh command: {cmd}")
|
||||
LOG.debug('ssh command: %s', cmd)
|
||||
# we intentionally pass through user-provided arguments and run this in
|
||||
# the user's shell
|
||||
os.system(cmd) # noqa: S605
|
||||
|
||||
@@ -622,7 +622,7 @@ class CreateImage(command.ShowOne):
|
||||
)
|
||||
# TODO(stephenfin): These should be an error in a future
|
||||
# version
|
||||
LOG.warning(msg % opt_name)
|
||||
LOG.warning(msg, opt_name)
|
||||
|
||||
source_volume = volume_client.find_volume(
|
||||
parsed_args.volume, ignore_missing=False
|
||||
|
||||
@@ -129,7 +129,10 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
|
||||
utils, 'find_resource', side_effect=find_mock_result
|
||||
) as find_mock:
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
mock_error.assert_called_with("1 of 2 volumes failed to add.")
|
||||
mock_error.assert_called_with(
|
||||
'%(result)s of %(total)s volumes failed to add.',
|
||||
{'result': 1, 'total': 2},
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
find_mock.assert_any_call(
|
||||
self.consistencygroups_mock, self._consistency_group.id
|
||||
@@ -602,7 +605,10 @@ class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
|
||||
utils, 'find_resource', side_effect=find_mock_result
|
||||
) as find_mock:
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
mock_error.assert_called_with("1 of 2 volumes failed to remove.")
|
||||
mock_error.assert_called_with(
|
||||
'%(result)s of %(total)s volumes failed to remove.',
|
||||
{'result': 1, 'total': 2},
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
find_mock.assert_any_call(
|
||||
self.consistencygroups_mock, self._consistency_group.id
|
||||
|
||||
@@ -1618,7 +1618,8 @@ class TestVolumeSet(TestVolume):
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.volumes_mock.retype.assert_not_called()
|
||||
mock_warning.assert_called_with(
|
||||
"'--retype-policy' option will not work without '--type' option"
|
||||
"'%s' option will not work without '--type' option",
|
||||
'--retype-policy',
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
@@ -1998,7 +1998,8 @@ class TestVolumeSet(volume_fakes.TestVolume):
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
self.volumes_mock.retype.assert_not_called()
|
||||
mock_warning.assert_called_with(
|
||||
"'--retype-policy' option will not work without '--type' option"
|
||||
"'%s' option will not work without '--type' option",
|
||||
'--retype-policy',
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ def _find_volumes(parsed_args_volumes, volume_client):
|
||||
except Exception as e:
|
||||
result += 1
|
||||
LOG.error(
|
||||
_("Failed to find volume with name or ID '%(volume)s':%(e)s")
|
||||
% {'volume': volume, 'e': e}
|
||||
_("Failed to find volume with name or ID '%(volume)s':%(e)s"),
|
||||
{'volume': volume, 'e': e},
|
||||
)
|
||||
|
||||
return result, uuid
|
||||
@@ -73,8 +73,8 @@ class AddVolumeToConsistencyGroup(command.Command):
|
||||
if result > 0:
|
||||
total = len(parsed_args.volumes)
|
||||
LOG.error(
|
||||
_("%(result)s of %(total)s volumes failed to add.")
|
||||
% {'result': result, 'total': total}
|
||||
_("%(result)s of %(total)s volumes failed to add."),
|
||||
{'result': result, 'total': total},
|
||||
)
|
||||
|
||||
if add_uuid:
|
||||
@@ -226,8 +226,8 @@ class DeleteConsistencyGroup(command.Command):
|
||||
_(
|
||||
"Failed to delete consistency group with "
|
||||
"name or ID '%(consistency_group)s':%(e)s"
|
||||
)
|
||||
% {'consistency_group': i, 'e': e}
|
||||
),
|
||||
{'consistency_group': i, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
@@ -317,8 +317,8 @@ class RemoveVolumeFromConsistencyGroup(command.Command):
|
||||
if result > 0:
|
||||
total = len(parsed_args.volumes)
|
||||
LOG.error(
|
||||
_("%(result)s of %(total)s volumes failed to remove.")
|
||||
% {'result': result, 'total': total}
|
||||
_("%(result)s of %(total)s volumes failed to remove."),
|
||||
{'result': result, 'total': total},
|
||||
)
|
||||
|
||||
if remove_uuid:
|
||||
|
||||
@@ -101,8 +101,8 @@ class DeleteConsistencyGroupSnapshot(command.Command):
|
||||
_(
|
||||
"Failed to delete consistency group snapshot "
|
||||
"with name or ID '%(snapshot)s': %(e)s"
|
||||
)
|
||||
% {'snapshot': snapshot, 'e': e}
|
||||
),
|
||||
{'snapshot': snapshot, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
|
||||
@@ -146,8 +146,8 @@ class DeleteQos(command.Command):
|
||||
_(
|
||||
"Failed to delete QoS specification with "
|
||||
"name or ID '%(qos)s': %(e)s"
|
||||
)
|
||||
% {'qos': i, 'e': e}
|
||||
),
|
||||
{'qos': i, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
|
||||
@@ -910,12 +910,12 @@ class SetVolume(command.Command):
|
||||
elif policy:
|
||||
# If the "--migration-policy" is specified without "--type"
|
||||
LOG.warning(
|
||||
_("'%s' option will not work without '--type' option")
|
||||
% (
|
||||
_("'%s' option will not work without '--type' option"),
|
||||
(
|
||||
'--migration-policy'
|
||||
if parsed_args.migration_policy
|
||||
else '--retype-policy'
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
kwargs = {}
|
||||
|
||||
@@ -175,8 +175,8 @@ class DeleteVolumeBackup(command.Command):
|
||||
_(
|
||||
"Failed to delete backup with "
|
||||
"name or ID '%(backup)s': %(e)s"
|
||||
)
|
||||
% {'backup': backup, 'e': e}
|
||||
),
|
||||
{'backup': backup, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
|
||||
@@ -228,8 +228,8 @@ class DeleteVolumeSnapshot(command.Command):
|
||||
_(
|
||||
"Failed to delete snapshot with "
|
||||
"name or ID '%(snapshot)s': %(e)s"
|
||||
)
|
||||
% {'snapshot': snapshot, 'e': e}
|
||||
),
|
||||
{'snapshot': snapshot, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
|
||||
@@ -128,8 +128,8 @@ class DeleteTransferRequest(command.Command):
|
||||
_(
|
||||
"Failed to delete volume transfer request "
|
||||
"with name or ID '%(transfer)s': %(e)s"
|
||||
)
|
||||
% {'transfer': t, 'e': e}
|
||||
),
|
||||
{'transfer': t, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
|
||||
@@ -277,7 +277,7 @@ class CreateVolumeType(command.ShowOne):
|
||||
msg = _(
|
||||
"Failed to add project %(project)s access to type: %(e)s"
|
||||
)
|
||||
LOG.error(msg % {'project': parsed_args.project, 'e': e})
|
||||
LOG.error(msg, {'project': parsed_args.project, 'e': e})
|
||||
|
||||
properties = {}
|
||||
if parsed_args.properties:
|
||||
@@ -358,8 +358,8 @@ class DeleteVolumeType(command.Command):
|
||||
_(
|
||||
"Failed to delete volume type with "
|
||||
"name or ID '%(volume_type)s': %(e)s"
|
||||
)
|
||||
% {'volume_type': volume_type, 'e': e}
|
||||
),
|
||||
{'volume_type': volume_type, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
@@ -763,7 +763,7 @@ class ShowVolumeType(command.ShowOne):
|
||||
'Failed to get access project list for volume type '
|
||||
'%(type)s: %(e)s'
|
||||
)
|
||||
LOG.error(msg % {'type': volume_type.id, 'e': e})
|
||||
LOG.error(msg, {'type': volume_type.id, 'e': e})
|
||||
volume_type._info.update({'access_project_ids': access_project_ids})
|
||||
if parsed_args.encryption_type:
|
||||
# show encryption type information for this volume type
|
||||
|
||||
@@ -1071,12 +1071,12 @@ class SetVolume(command.Command):
|
||||
elif policy:
|
||||
# If the "--migration-policy" is specified without "--type"
|
||||
LOG.warning(
|
||||
_("'%s' option will not work without '--type' option")
|
||||
% (
|
||||
_("'%s' option will not work without '--type' option"),
|
||||
(
|
||||
'--migration-policy'
|
||||
if parsed_args.migration_policy
|
||||
else '--retype-policy'
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
kwargs = {}
|
||||
|
||||
@@ -218,8 +218,8 @@ class DeleteVolumeBackup(command.Command):
|
||||
_(
|
||||
"Failed to delete backup with "
|
||||
"name or ID '%(backup)s': %(e)s"
|
||||
)
|
||||
% {'backup': backup, 'e': e}
|
||||
),
|
||||
{'backup': backup, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
|
||||
@@ -246,8 +246,8 @@ class DeleteVolumeSnapshot(command.Command):
|
||||
_(
|
||||
"Failed to delete snapshot with "
|
||||
"name or ID '%(snapshot)s': %(e)s"
|
||||
)
|
||||
% {'snapshot': snapshot, 'e': e}
|
||||
),
|
||||
{'snapshot': snapshot, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
|
||||
@@ -163,8 +163,8 @@ class DeleteTransferRequest(command.Command):
|
||||
_(
|
||||
"Failed to delete volume transfer request "
|
||||
"with name or ID '%(transfer)s': %(e)s"
|
||||
)
|
||||
% {'transfer': t, 'e': e}
|
||||
),
|
||||
{'transfer': t, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
|
||||
@@ -277,7 +277,7 @@ class CreateVolumeType(command.ShowOne):
|
||||
msg = _(
|
||||
"Failed to add project %(project)s access to type: %(e)s"
|
||||
)
|
||||
LOG.error(msg % {'project': parsed_args.project, 'e': e})
|
||||
LOG.error(msg, {'project': parsed_args.project, 'e': e})
|
||||
|
||||
properties = {}
|
||||
if parsed_args.properties:
|
||||
@@ -358,8 +358,8 @@ class DeleteVolumeType(command.Command):
|
||||
_(
|
||||
"Failed to delete volume type with "
|
||||
"name or ID '%(volume_type)s': %(e)s"
|
||||
)
|
||||
% {'volume_type': volume_type, 'e': e}
|
||||
),
|
||||
{'volume_type': volume_type, 'e': e},
|
||||
)
|
||||
|
||||
if result > 0:
|
||||
@@ -846,7 +846,7 @@ class ShowVolumeType(command.ShowOne):
|
||||
'Failed to get access project list for volume type '
|
||||
'%(type)s: %(e)s'
|
||||
)
|
||||
LOG.error(msg % {'type': volume_type.id, 'e': e})
|
||||
LOG.error(msg, {'type': volume_type.id, 'e': e})
|
||||
volume_type._info.update({'access_project_ids': access_project_ids})
|
||||
if parsed_args.encryption_type:
|
||||
# show encryption type information for this volume type
|
||||
|
||||
@@ -758,7 +758,7 @@ quote-style = "preserve"
|
||||
docstring-code-format = true
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E4", "E5", "E7", "E9", "F", "S", "UP"]
|
||||
select = ["E4", "E5", "E7", "E9", "F", "G", "S", "UP"]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"openstackclient/tests/*" = ["E501", "S"]
|
||||
|
||||
Reference in New Issue
Block a user