From: Štěpán Balážik Date: Tue, 27 Jan 2026 23:41:06 +0000 (+0100) Subject: Fix some 'Formatting a regular string which could be an f-string' errors X-Git-Tag: v9.21.19~15^2~23 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=df0be6b4bd2a20c1648c60967e76ff5dcbbcdad9;p=thirdparty%2Fbind9.git Fix some 'Formatting a regular string which could be an f-string' errors Generated with: ruff check --select UP031,UP032 --fix --unsafe-fixes && black . --- diff --git a/bin/tests/system/doth/stress_http_quota.py b/bin/tests/system/doth/stress_http_quota.py index ca1fddbcc66..930f944adf4 100755 --- a/bin/tests/system/doth/stress_http_quota.py +++ b/bin/tests/system/doth/stress_http_quota.py @@ -228,8 +228,8 @@ def run_test(http_secure=True): assert subdig.alive(), "The single DIG instance is expected to be alive" assert multidig.alive(), ( "The DIG instances from the set are all expected to " - "be alive, but {} of them have completed" - ).format(multidig.completed()) + f"be alive, but {multidig.completed()} of them have completed" + ) # Let's close opened connections (in random order) to let all dig # processes to complete connector.disconnect_all() diff --git a/bin/tests/system/statschannel/generic.py b/bin/tests/system/statschannel/generic.py index fa64f5c483b..e77f3fc37fa 100644 --- a/bin/tests/system/statschannel/generic.py +++ b/bin/tests/system/statschannel/generic.py @@ -69,7 +69,7 @@ def check_manykeys(name, zone=None): def zone_mtime(zonedir, name): try: - si = os.stat(os.path.join(zonedir, "{}.db".format(name))) + si = os.stat(os.path.join(zonedir, f"{name}.db")) except FileNotFoundError: return dayzero @@ -160,7 +160,7 @@ def create_expected(data): def update_expected(expected, key, msg): msg_len = len(msg.to_wire()) bucket_num = (msg_len // 16) * 16 - bucket = "{}-{}".format(bucket_num, bucket_num + 15) + bucket = f"{bucket_num}-{bucket_num + 15}" expected[key][bucket] += 1 diff --git a/bin/tests/system/statschannel/tests_json.py b/bin/tests/system/statschannel/tests_json.py index 926da5dab4e..72a6e41e1b0 100755 --- a/bin/tests/system/statschannel/tests_json.py +++ b/bin/tests/system/statschannel/tests_json.py @@ -46,9 +46,7 @@ pytestmark = [ # JSON helper functions def fetch_zones_json(statsip, statsport): - r = requests.get( - "http://{}:{}/json/v1/zones".format(statsip, statsport), timeout=600 - ) + r = requests.get(f"http://{statsip}:{statsport}/json/v1/zones", timeout=600) assert r.status_code == 200 data = r.json() @@ -56,9 +54,7 @@ def fetch_zones_json(statsip, statsport): def fetch_traffic_json(statsip, statsport): - r = requests.get( - "http://{}:{}/json/v1/traffic".format(statsip, statsport), timeout=600 - ) + r = requests.get(f"http://{statsip}:{statsport}/json/v1/traffic", timeout=600) assert r.status_code == 200 data = r.json() diff --git a/bin/tests/system/statschannel/tests_xml.py b/bin/tests/system/statschannel/tests_xml.py index b7a1992846b..e0c8dd3425d 100755 --- a/bin/tests/system/statschannel/tests_xml.py +++ b/bin/tests/system/statschannel/tests_xml.py @@ -46,9 +46,7 @@ pytestmark = [ # XML helper functions def fetch_zones_xml(statsip, statsport): - r = requests.get( - "http://{}:{}/xml/v3/zones".format(statsip, statsport), timeout=600 - ) + r = requests.get(f"http://{statsip}:{statsport}/xml/v3/zones", timeout=600) assert r.status_code == 200 root = ET.fromstring(r.text) @@ -71,9 +69,7 @@ def fetch_traffic_xml(statsip, statsport): return out - r = requests.get( - "http://{}:{}/xml/v3/traffic".format(statsip, statsport), timeout=600 - ) + r = requests.get(f"http://{statsip}:{statsport}/xml/v3/traffic", timeout=600) assert r.status_code == 200 root = ET.fromstring(r.text) @@ -84,9 +80,9 @@ def fetch_traffic_xml(statsip, statsport): proto_root = root.find("traffic").find(ip).find(proto) for counters in proto_root.findall("counters"): if counters.attrib["type"] == "request-size": - key = "dns-{}-requests-sizes-received-{}".format(proto, ip) + key = f"dns-{proto}-requests-sizes-received-{ip}" else: - key = "dns-{}-responses-sizes-sent-{}".format(proto, ip) + key = f"dns-{proto}-responses-sizes-sent-{ip}" values = load_counters(counters) traffic[key] = values diff --git a/bin/tests/system/tcp/ans6/ans.py b/bin/tests/system/tcp/ans6/ans.py index 1617f31ddcd..04d21a96be4 100644 --- a/bin/tests/system/tcp/ans6/ans.py +++ b/bin/tests/system/tcp/ans6/ans.py @@ -65,7 +65,7 @@ def open_connections(active_conns, count, host, port): sock.setblocking(0) err = sock.connect_ex((host, port)) if err not in (0, errno.EINPROGRESS): - log("%s on connect for socket %s" % (errno.errorcode[err], sock)) + log(f"{errno.errorcode[err]} on connect for socket {sock}") errors.append(sock) else: queued.append(sock) @@ -81,7 +81,7 @@ def open_connections(active_conns, count, host, port): queued.remove(sock) err = sock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) if err: - log("%s for socket %s" % (errno.errorcode[err], sock)) + log(f"{errno.errorcode[err]} for socket {sock}") errors.append(sock) else: sock.send(VERSION_QUERY) @@ -98,7 +98,7 @@ def open_connections(active_conns, count, host, port): def close_connections(active_conns, count): - log("Closing %s connections..." % "all" if count == 0 else str(count)) + log("Closing {} connections...".format("all") if count == 0 else str(count)) if count == 0: count = len(active_conns) for _ in range(count): @@ -136,10 +136,10 @@ def main(): while True: clientsock, _ = ctlsock.accept() - log("Accepted control connection from %s" % clientsock) + log(f"Accepted control connection from {clientsock}") cmdline = clientsock.recv(512).decode("ascii").strip() if cmdline: - log("Received command: %s" % cmdline) + log(f"Received command: {cmdline}") cmd = cmdline.split() if cmd[0] == "open": count, host, port = cmd[1:] diff --git a/util/parse_tsan.py b/util/parse_tsan.py index 28afc34bff6..a2a4bda34b2 100755 --- a/util/parse_tsan.py +++ b/util/parse_tsan.py @@ -107,13 +107,13 @@ with open(sys.argv[1], "r", encoding="utf-8") as f: S.p_index += 1 for k, v in S.mutexes.items(): r = re.compile(k) - line = r.sub("M{:04d}".format(v), line) + line = r.sub(f"M{v:04d}", line) for k, v in S.threads.items(): r = re.compile(k) - line = r.sub("T{:04d}".format(v), line) + line = r.sub(f"T{v:04d}", line) for k, v in S.pointers.items(): r = re.compile(k) - line = r.sub("0x{:012d}".format(v), line) + line = r.sub(f"0x{v:012d}", line) line = STACK.sub("", line) line = PID.sub("", line)