Skip to content

Commit 55e862b

Browse files
committed
trivial: Enable flake8-logging-format (G) rules
Change-Id: Iabc94a0fd40903dc2a81bf62aea8460f20a7e0e4 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent 164e5d0 commit 55e862b

21 files changed

Lines changed: 66 additions & 49 deletions

examples/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def main(opts, run):
264264
if dump_stack_trace:
265265
_logger.error(traceback.format_exc(e))
266266
else:
267-
_logger.error('Exception raised: ' + str(e))
267+
_logger.error('Exception raised: %s', e)
268268
return 1
269269

270270

openstackclient/common/quota.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@ def _list_quota_compute(self, parsed_args, project_ids):
272272
sdk_exceptions.NotFoundException,
273273
) as exc:
274274
# Project not found, move on to next one
275-
LOG.warning(f"Project {project_id} not found: {exc}")
275+
LOG.warning(
276+
'Project %(project_id)s not found: %(exc)s',
277+
{'project_id': project_id, 'exc': exc},
278+
)
276279
continue
277280

278281
project_result = _xform_get_quota(
@@ -334,7 +337,10 @@ def _list_quota_volume(self, parsed_args, project_ids):
334337
sdk_exceptions.NotFoundException,
335338
) as exc:
336339
# Project not found, move on to next one
337-
LOG.warning(f"Project {project_id} not found: {exc}")
340+
LOG.warning(
341+
'Project %(project_id)s not found: %(exc)s',
342+
{'project_id': project_id, 'exc': exc},
343+
)
338344
continue
339345

340346
project_result = _xform_get_quota(
@@ -389,7 +395,10 @@ def _list_quota_network(self, parsed_args, project_ids):
389395
sdk_exceptions.ForbiddenException,
390396
) as exc:
391397
# Project not found, move on to next one
392-
LOG.warning(f"Project {project_id} not found: {exc}")
398+
LOG.warning(
399+
'Project %(project_id)s not found: %(exc)s',
400+
{'project_id': project_id, 'exc': exc},
401+
)
393402
continue
394403

395404
project_result = _xform_get_quota(

openstackclient/compute/v2/server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5018,7 +5018,7 @@ def take_action(self, parsed_args):
50185018
)
50195019

50205020
cmd = ' '.join(['ssh', ip_address] + args)
5021-
LOG.debug(f"ssh command: {cmd}")
5021+
LOG.debug('ssh command: %s', cmd)
50225022
# we intentionally pass through user-provided arguments and run this in
50235023
# the user's shell
50245024
os.system(cmd) # noqa: S605

openstackclient/image/v2/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def _take_action_volume(self, parsed_args):
622622
)
623623
# TODO(stephenfin): These should be an error in a future
624624
# version
625-
LOG.warning(msg % opt_name)
625+
LOG.warning(msg, opt_name)
626626

627627
source_volume = volume_client.find_volume(
628628
parsed_args.volume, ignore_missing=False

openstackclient/tests/unit/volume/v2/test_consistency_group.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ def test_add_multiple_volumes_to_consistency_group_with_exception(
129129
utils, 'find_resource', side_effect=find_mock_result
130130
) as find_mock:
131131
result = self.cmd.take_action(parsed_args)
132-
mock_error.assert_called_with("1 of 2 volumes failed to add.")
132+
mock_error.assert_called_with(
133+
'%(result)s of %(total)s volumes failed to add.',
134+
{'result': 1, 'total': 2},
135+
)
133136
self.assertIsNone(result)
134137
find_mock.assert_any_call(
135138
self.consistencygroups_mock, self._consistency_group.id
@@ -602,7 +605,10 @@ def test_remove_multiple_volumes_from_consistency_group_with_exception(
602605
utils, 'find_resource', side_effect=find_mock_result
603606
) as find_mock:
604607
result = self.cmd.take_action(parsed_args)
605-
mock_error.assert_called_with("1 of 2 volumes failed to remove.")
608+
mock_error.assert_called_with(
609+
'%(result)s of %(total)s volumes failed to remove.',
610+
{'result': 1, 'total': 2},
611+
)
606612
self.assertIsNone(result)
607613
find_mock.assert_any_call(
608614
self.consistencygroups_mock, self._consistency_group.id

openstackclient/tests/unit/volume/v2/test_volume.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,8 @@ def test_volume_set_with_only_retype_policy(self, mock_warning):
16181618
result = self.cmd.take_action(parsed_args)
16191619
self.volumes_mock.retype.assert_not_called()
16201620
mock_warning.assert_called_with(
1621-
"'--retype-policy' option will not work without '--type' option"
1621+
"'%s' option will not work without '--type' option",
1622+
'--retype-policy',
16221623
)
16231624
self.assertIsNone(result)
16241625

openstackclient/tests/unit/volume/v3/test_volume.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,8 @@ def test_volume_set_with_only_retype_policy(self, mock_warning):
19981998
result = self.cmd.take_action(parsed_args)
19991999
self.volumes_mock.retype.assert_not_called()
20002000
mock_warning.assert_called_with(
2001-
"'--retype-policy' option will not work without '--type' option"
2001+
"'%s' option will not work without '--type' option",
2002+
'--retype-policy',
20022003
)
20032004
self.assertIsNone(result)
20042005

openstackclient/volume/v2/consistency_group.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def _find_volumes(parsed_args_volumes, volume_client):
3838
except Exception as e:
3939
result += 1
4040
LOG.error(
41-
_("Failed to find volume with name or ID '%(volume)s':%(e)s")
42-
% {'volume': volume, 'e': e}
41+
_("Failed to find volume with name or ID '%(volume)s':%(e)s"),
42+
{'volume': volume, 'e': e},
4343
)
4444

4545
return result, uuid
@@ -73,8 +73,8 @@ def take_action(self, parsed_args):
7373
if result > 0:
7474
total = len(parsed_args.volumes)
7575
LOG.error(
76-
_("%(result)s of %(total)s volumes failed to add.")
77-
% {'result': result, 'total': total}
76+
_("%(result)s of %(total)s volumes failed to add."),
77+
{'result': result, 'total': total},
7878
)
7979

8080
if add_uuid:
@@ -226,8 +226,8 @@ def take_action(self, parsed_args):
226226
_(
227227
"Failed to delete consistency group with "
228228
"name or ID '%(consistency_group)s':%(e)s"
229-
)
230-
% {'consistency_group': i, 'e': e}
229+
),
230+
{'consistency_group': i, 'e': e},
231231
)
232232

233233
if result > 0:
@@ -317,8 +317,8 @@ def take_action(self, parsed_args):
317317
if result > 0:
318318
total = len(parsed_args.volumes)
319319
LOG.error(
320-
_("%(result)s of %(total)s volumes failed to remove.")
321-
% {'result': result, 'total': total}
320+
_("%(result)s of %(total)s volumes failed to remove."),
321+
{'result': result, 'total': total},
322322
)
323323

324324
if remove_uuid:

openstackclient/volume/v2/consistency_group_snapshot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def take_action(self, parsed_args):
101101
_(
102102
"Failed to delete consistency group snapshot "
103103
"with name or ID '%(snapshot)s': %(e)s"
104-
)
105-
% {'snapshot': snapshot, 'e': e}
104+
),
105+
{'snapshot': snapshot, 'e': e},
106106
)
107107

108108
if result > 0:

openstackclient/volume/v2/qos_specs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def take_action(self, parsed_args):
146146
_(
147147
"Failed to delete QoS specification with "
148148
"name or ID '%(qos)s': %(e)s"
149-
)
150-
% {'qos': i, 'e': e}
149+
),
150+
{'qos': i, 'e': e},
151151
)
152152

153153
if result > 0:

0 commit comments

Comments
 (0)