From: Jörg Behrmann Date: Tue, 23 Dec 2025 16:12:40 +0000 (+0100) Subject: Fix: capturing of loop variable for systemd-dissect call X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6198f2c50e61da04742abf1483082ff95b1a938d;p=thirdparty%2Fmkosi.git Fix: capturing of loop variable for systemd-dissect call This fixes B023 [1]. Before only the last loop value would be captured. [1] https://docs.astral.sh/ruff/rules/function-uses-loop-variable/ --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index ec6a87855..5299dda1d 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -198,7 +198,11 @@ def mount_base_trees(context: Context) -> Iterator[None]: ["systemd-dissect", "--mount", "--mkdir", path, d], env=dict(SYSTEMD_DISSECT_VERITY_EMBEDDED="no", SYSTEMD_DISSECT_VERITY_SIDECAR="no"), ) - stack.callback(lambda: run(["systemd-dissect", "--umount", "--rmdir", d])) + + def _umount(d: PathString = d) -> None: + run(["systemd-dissect", "--umount", "--rmdir", d]) + + stack.callback(_umount) bases += [d] else: die(f"Unsupported base tree source {path}")