From c33794470c59d94513d8be2d510af896381af2ce Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 1 Aug 2025 13:01:32 +0100 Subject: [PATCH] Enable ruff UP031 This is kept separate since it is a little more intricate. Change-Id: If340ff5c1e44a1b42fb2a34806d7e8a0164432ec Signed-off-by: Stephen Finucane --- oslo_utils/excutils.py | 4 +-- oslo_utils/imageutils/format_inspector.py | 12 +++++---- .../tests/imageutils/test_format_inspector.py | 27 ++++++++++--------- oslo_utils/tests/imageutils/test_qemu.py | 8 +++--- oslo_utils/tests/test_excutils.py | 6 ++--- pyproject.toml | 1 - tools/perf_test_mask_password.py | 2 +- 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/oslo_utils/excutils.py b/oslo_utils/excutils.py index ae5f7e31..a3b15bf1 100644 --- a/oslo_utils/excutils.py +++ b/oslo_utils/excutils.py @@ -274,8 +274,8 @@ def forever_retry_uncaught_exceptions(*args, **kwargs): # The watch has expired or the exception message # changed, so time to log it again... logging.exception( - 'Unexpected exception occurred %d time(s)... ' - 'retrying.' % same_failure_count + f'Unexpected exception occurred ' + f'{same_failure_count} time(s)... retrying.' ) if not watch.has_started(): watch.start() diff --git a/oslo_utils/imageutils/format_inspector.py b/oslo_utils/imageutils/format_inspector.py index 329fcfb1..5433e435 100644 --- a/oslo_utils/imageutils/format_inspector.py +++ b/oslo_utils/imageutils/format_inspector.py @@ -792,7 +792,7 @@ class VHDXInspector(FileInspector): ) if count >= 2048: - raise ImageFormatError('Region count is %i (limit 2047)' % count) + raise ImageFormatError('Region count is {int(count)} (limit 2047)') # Process the regions until we find the metadata one; grab the # offset and return @@ -849,7 +849,7 @@ class VHDXInspector(FileInspector): if count >= 2048: raise ImageFormatError( - 'Metadata item count is %i (limit 2047)' % count + 'Metadata item count is {int(count)} (limit 2047)' ) for i in range(0, count): @@ -1003,7 +1003,7 @@ class VMDKInspector(FileInspector): raise ImageFormatError(f'Signature KDMV not found: {sig!r}') if ver not in (1, 2, 3): - raise ImageFormatError('Unsupported format version %i' % ver) + raise ImageFormatError('Unsupported format version {int(ver)}') if gdOffset == self.GD_AT_END and not self.has_region('footer'): # This means we have a footer, which takes precedence over the @@ -1364,7 +1364,9 @@ class GPTInspector(FileInspector): sizelba, ) = struct.unpack('