chore(lint): apply the 3.1 f-string wave to the kernel-datapath code

The rebase onto 65c858d45 brought upstream's UP032 enforcement; the
conflict resolution kept this branch's semantics on the overlapping
lines, so their .format() calls needed the conversion afterwards
(ruff check --fix, 41 sites) plus the formatter's rewrap (7 files).

Replicates the CI recipe locally: pip check, ruff check/format, mypy
2.3.1 (clean, 434 files), unit suite 2216 passed.
This commit is contained in:
YueGuobin committed 2026-10-06 00:28:06 +08:00
1 parent 5841138cef
commit 87ca2138e3
9 files changed
+49 -158

No files matched your search

@@ -101,11 +101,7 @@ class DockerKernelDatapathMixin(KernelDatapathMixin):
try:
adapter = self._ethernet_adapters[adapter_number]
except IndexError:
raise DockerError(
"Adapter {adapter_number} doesn't exist on Docker container '{name}'".format(
name=self.name, adapter_number=adapter_number
)
)
raise DockerError(f"Adapter {adapter_number} doesn't exist on Docker container '{self.name}'")
host_ifc, guest_ifc = self._veth_names(adapter_number, port_number)
# The host end lives in the root namespace and survives container
@@ -144,12 +140,7 @@ class DockerKernelDatapathMixin(KernelDatapathMixin):
adapter.host_ifc = host_ifc
self._kernel_veths[(adapter_number, port_number)] = host_ifc
log.debug(
"Created veth adapter {adapter_number} port {port_number} with MAC address {mac_address} in namespace {namespace}".format(
adapter_number=adapter_number,
port_number=port_number,
mac_address=mac_address,
namespace=self._namespace,
)
f"Created veth adapter {adapter_number} port {port_number} with MAC address {mac_address} in namespace {self._namespace}"
)
async def _remove_kernel_veths(self):
+4 -14
View File
@@ -1815,11 +1815,9 @@ class DockerVM(DockerKernelDatapathMixin, BaseNode):
# rejected earlier): the kernel path needs an anchor — the
# veth host end, or the persistent TAP of an IOL runner.
raise DockerError(
"Adapter {adapter_number} port {port_number} of container '{name}' has no host-side "
f"Adapter {adapter_number} port {port_number} of container '{self.name}' has no host-side "
"anchor interface (it was started before the unified-veth datapath); "
"restart the node to attach a kernel link to it".format(
adapter_number=adapter_number, port_number=port_number, name=self.name
)
"restart the node to attach a kernel link to it"
)
# The mechanics (bridge create/addif, capture, markers, filters)
# live in KernelDatapathMixin, shared with every other node type
@@ -1845,11 +1843,7 @@ class DockerVM(DockerKernelDatapathMixin, BaseNode):
# NIO sets it back down).
await self._ubridge_send(f'link set "{host_ifc}" up')
await self._ubridge_send(f'bridge add_nio_ethernet {bridge_name} "{host_ifc}"')
await self._ubridge_send(
"bridge add_nio_udp {bridge_name} {lport} {rhost} {rport}".format(
bridge_name=bridge_name, lport=nio.lport, rhost=nio.rhost, rport=nio.rport
)
)
await self._ubridge_send(f"bridge add_nio_udp {bridge_name} {nio.lport} {nio.rhost} {nio.rport}")
if nio.capturing:
await self._ubridge_send(f'bridge start_capture {bridge_name} "{nio.pcap_output_file}"')
await self._ubridge_send(f"bridge start {bridge_name}")
@@ -1934,11 +1928,7 @@ class DockerVM(DockerKernelDatapathMixin, BaseNode):
if self.status == "started":
await self._set_adapter_carrier(adapter_number, False, port_number)
await self._ubridge_send(f"bridge stop {bridge_name}")
await self._ubridge_send(
"bridge remove_nio_udp {bridge_name} {lport} {rhost} {rport}".format(
bridge_name=bridge_name, lport=nio.lport, rhost=nio.rhost, rport=nio.rport
)
)
await self._ubridge_send(f"bridge remove_nio_udp {bridge_name} {nio.lport} {nio.rhost} {nio.rport}")
adapter.remove_nio(port_number)
+2 -2
View File
@@ -573,10 +573,10 @@ class IOLDockerVM(VendorDockerVM):
anchor = self._kernel_host_ifc(adapter_number, port_number)
if anchor is None:
raise DockerError(
"Bay {bay}/{unit} of IOL container '{name}' has no TAP anchor to carry a kernel "
f"Bay {adapter_number}/{port_number} of IOL container '{self._name}' has no TAP anchor to carry a kernel "
"link (this compute's uBridge lacks the tap module or bridge delete_nio_tap, "
"or the node was started before the kernel-datapath support); restart the "
"node after upgrading uBridge".format(bay=adapter_number, unit=port_number, name=self._name)
"node after upgrading uBridge"
)
await self._ensure_unix_port_bridge(adapter_number, port_number)
await self._ensure_anchor(adapter_number, port_number)