From 41dedd16c7d7ef67169035effd95371c497e2be6 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 5 Oct 2025 19:38:47 +0900 Subject: [PATCH] Bump pyupgrade target to 3.10+ ... according to the versions currently supported. Change-Id: I13138e4324c4f5fdb7cc5b0f963f417dfeb6f246 Signed-off-by: Takashi Kajinami --- .pre-commit-config.yaml | 2 +- oslo_privsep/comm.py | 4 ++-- oslo_privsep/daemon.py | 6 +++--- oslo_privsep/priv_context.py | 2 +- oslo_privsep/tests/test_priv_context.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 777d047..7296310 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,4 +26,4 @@ repos: rev: v3.20.0 hooks: - id: pyupgrade - args: [--py3-only] + args: [--py310-plus] diff --git a/oslo_privsep/comm.py b/oslo_privsep/comm.py index ace17cf..3d96278 100644 --- a/oslo_privsep/comm.py +++ b/oslo_privsep/comm.py @@ -92,7 +92,7 @@ class Deserializer: if not buf: raise self.unpacker.feed(buf) - except socket.timeout: + except TimeoutError: pass @@ -193,7 +193,7 @@ class ClientChannel: reply = future.result() except Exception: - LOG.warning("Unexpected error: {}".format(sys.exc_info()[0])) + LOG.warning(f"Unexpected error: {sys.exc_info()[0]}") raise finally: del self.outstanding_msgs[myid] diff --git a/oslo_privsep/daemon.py b/oslo_privsep/daemon.py index 463d37b..2a2c342 100644 --- a/oslo_privsep/daemon.py +++ b/oslo_privsep/daemon.py @@ -223,7 +223,7 @@ class _ClientChannel(comm.ClientChannel): exc_type = importutils.import_class(result[1]) if self.log_traceback: try: - msg = 'Privsep daemon traceback: {}'.format(result[3]) + msg = f'Privsep daemon traceback: {result[3]}' self.log.warning(msg) except IndexError: pass @@ -493,7 +493,7 @@ class Daemon: 'privsep: Exception during request[%(msgid)s]: ' '%(err)s', {'msgid': msgid, 'err': e}, exc_info=True) cls = e.__class__ - cls_name = '{}.{}'.format(cls.__module__, cls.__name__) + cls_name = f'{cls.__module__}.{cls.__name__}' return (comm.Message.ERR.value, cls_name, e.args, traceback.format_exc()) @@ -522,7 +522,7 @@ class Daemon: 'privsep: Exception during request[%(msgid)s]: ' '%(err)s', {'msgid': msgid, 'err': e}, exc_info=True) cls = e.__class__ - cls_name = '{}.{}'.format(cls.__module__, cls.__name__) + cls_name = f'{cls.__module__}.{cls.__name__}' reply = (comm.Message.ERR.value, cls_name, e.args, traceback.format_exc()) try: diff --git a/oslo_privsep/priv_context.py b/oslo_privsep/priv_context.py index 8af20e4..e49c179 100644 --- a/oslo_privsep/priv_context.py +++ b/oslo_privsep/priv_context.py @@ -257,7 +257,7 @@ class PrivContext: def _wrap(self, func, *args, _wrap_timeout=None, **kwargs): if self.client_mode: - name = '{}.{}'.format(func.__module__, func.__name__) + name = f'{func.__module__}.{func.__name__}' if self.channel is not None and not self.channel.running: LOG.warning("RESTARTING PrivContext for %s", name) self.stop() diff --git a/oslo_privsep/tests/test_priv_context.py b/oslo_privsep/tests/test_priv_context.py index 6f6f6d5..ac0e4f8 100644 --- a/oslo_privsep/tests/test_priv_context.py +++ b/oslo_privsep/tests/test_priv_context.py @@ -55,7 +55,7 @@ class CustomError(Exception): self.msg = msg def __str__(self): - return 'Code {}: {}'.format(self.code, self.msg) + return f'Code {self.code}: {self.msg}' @testctx.context.entrypoint