]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix some 'Formatting a regular string which could be an f-string' errors
authorŠtěpán Balážik <stepan@isc.org>
Tue, 27 Jan 2026 23:41:06 +0000 (00:41 +0100)
committerŠtěpán Balážik <stepan@isc.org>
Fri, 20 Feb 2026 14:17:31 +0000 (15:17 +0100)
Generated with:
ruff check --select UP031,UP032 --fix --unsafe-fixes && black .

bin/tests/system/doth/stress_http_quota.py
bin/tests/system/statschannel/generic.py
bin/tests/system/statschannel/tests_json.py
bin/tests/system/statschannel/tests_xml.py
bin/tests/system/tcp/ans6/ans.py
util/parse_tsan.py

index ca1fddbcc6606a1b2fac474fc22ddd3896fa5905..930f944adf4c5504e80aaa9ee10af39a64cc8003 100755 (executable)
@@ -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()
index fa64f5c483bb764df4318f7bba055ddbfeb56097..e77f3fc37fa938b0b27fd1ce6bf44120ee2e1021 100644 (file)
@@ -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
 
index 926da5dab4e8bb8662ef31d02d72bb45cdf290ce..72a6e41e1b0e637ca073171cee0ad1ea1b55a69b 100755 (executable)
@@ -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()
index b7a1992846b14cf9bd6dd594c89ed38346506ecd..e0c8dd3425d525952a0e9cedabfd3ac62ad5dee1 100755 (executable)
@@ -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
index 1617f31ddcd9bb9eb55e14a5274c9cc2626b58ce..04d21a96be4e8293ce137e5f3910f458369cea48 100644 (file)
@@ -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:]
index 28afc34bff68c881254a4c72fff9fe4bf2c80d1b..a2a4bda34b2dc960629c4dace6b47d3e2f3ba579 100755 (executable)
@@ -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)