From 7f3c0b99b724059035a3f89cb6c7bdc4780132ac Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 5 Oct 2025 19:44:50 +0900 Subject: [PATCH] Bump pyupgrade target to 3.10+ ... according to the versions currently supported. Change-Id: Iae501ca85ea947c86cb10c2631ea265ef97741ed Signed-off-by: Takashi Kajinami --- .pre-commit-config.yaml | 2 +- tooz/drivers/memcached.py | 2 +- tooz/drivers/pgsql.py | 4 ++-- tooz/drivers/redis.py | 2 +- tooz/drivers/zookeeper.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2fcc6501..aba69d2d 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/tooz/drivers/memcached.py b/tooz/drivers/memcached.py index dd3484f1..ad7f0a95 100644 --- a/tooz/drivers/memcached.py +++ b/tooz/drivers/memcached.py @@ -44,7 +44,7 @@ def _failure_translator(): except pymemcache_client.MemcacheUnexpectedCloseError as e: utils.raise_with_cause(coordination.ToozConnectionError, str(e), cause=e) - except (socket.timeout, OSError, socket.gaierror, socket.herror) as e: + except (TimeoutError, OSError, socket.gaierror, socket.herror) as e: # TODO(harlowja): get upstream pymemcache to produce a better # exception for these, using socket (vs. a memcache specific # error) seems sorta not right and/or the best approach... diff --git a/tooz/drivers/pgsql.py b/tooz/drivers/pgsql.py index 6c0df0fe..7589f889 100644 --- a/tooz/drivers/pgsql.py +++ b/tooz/drivers/pgsql.py @@ -53,7 +53,7 @@ _DIAGNOSTICS_ATTRS = tuple([ def _format_exception(e): lines = [ - "{}: {}".format(type(e).__name__, str(e).strip()), + f"{type(e).__name__}: {str(e).strip()}", ] if hasattr(e, 'pgcode') and e.pgcode is not None: lines.append("Error code: %s" % e.pgcode) @@ -68,7 +68,7 @@ def _format_exception(e): attr_value = getattr(e.diag, attr_name) if attr_value is None: continue - diagnostic_lines.append(" {} = {}".format(attr_name, attr_value)) + diagnostic_lines.append(f" {attr_name} = {attr_value}") if diagnostic_lines: lines.append('Diagnostics:') lines.extend(diagnostic_lines) diff --git a/tooz/drivers/redis.py b/tooz/drivers/redis.py index 0e266b54..9ffccca4 100644 --- a/tooz/drivers/redis.py +++ b/tooz/drivers/redis.py @@ -71,7 +71,7 @@ def _handle_failures(n_tries=15): class RedisLock(locking.Lock): def __init__(self, coord, client, name, timeout): - name = "{}_{}_lock".format(coord.namespace, str(name)) + name = f"{coord.namespace}_{str(name)}_lock" super().__init__(name) # NOTE(jd) Make sure we don't release and heartbeat at the same time by # using a exclusive access lock (LP#1557593) diff --git a/tooz/drivers/zookeeper.py b/tooz/drivers/zookeeper.py index 19dc0f1f..9c34167c 100644 --- a/tooz/drivers/zookeeper.py +++ b/tooz/drivers/zookeeper.py @@ -432,7 +432,7 @@ class KazooDriver(coordination.CoordinationDriverCachedRunWatchers): username = parsed_url.username password = parsed_url.password - digest_auth = "{}:{}".format(username, password) + digest_auth = f"{username}:{password}" digest_acl = security.make_digest_acl(username, password, all=True) default_acl = (digest_acl,) auth_data = [('digest', digest_auth)]