]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Remove unneeded lambdas
authorDaanDeMeyer <daan.j.demeyer@gmail.com>
Tue, 23 Dec 2025 19:58:15 +0000 (20:58 +0100)
committerJörg Behrmann <behrmann@physik.fu-berlin.de>
Wed, 24 Dec 2025 08:33:13 +0000 (09:33 +0100)
mkosi/__init__.py
mkosi/qemu.py
tests/test_initrd.py

index 5299dda1db2dbf74dc3ec436b146e3f22399a597..ac6705e7fec3a0632793a713dedf2807eacf9fa5 100644 (file)
@@ -3916,7 +3916,7 @@ def setup_workspace(args: Args, config: Config) -> Iterator[Path]:
         workspace.chmod(stat.S_IMODE(workspace.stat().st_mode) & ~(stat.S_ISGID | stat.S_ISUID))
         # Explicitly pass the "root" subdirectory first because on btrfs it's likely a subvolume and this
         # allows us to delete it with btrfs subvolume delete instead of a costly rm -rf.
-        stack.callback(lambda: rmtree(workspace / "root", workspace, sandbox=config.sandbox))
+        stack.callback(rmtree, workspace / "root", workspace, sandbox=config.sandbox)
         (workspace / "tmp").mkdir(mode=0o1777)
 
         with scopedenv({"TMPDIR": os.fspath(workspace / "tmp")}):
@@ -4240,9 +4240,7 @@ def run_shell(args: Args, config: Config) -> None:
         # Make sure the latest nspawn settings are always used.
         if config.nspawn_settings:
             if not (config.output_dir_or_cwd() / f"{name}.nspawn").exists():
-                stack.callback(
-                    lambda: (config.output_dir_or_cwd() / f"{name}.nspawn").unlink(missing_ok=True)
-                )
+                stack.callback((config.output_dir_or_cwd() / f"{name}.nspawn").unlink, missing_ok=True)
             copyfile2(config.nspawn_settings, config.output_dir_or_cwd() / f"{name}.nspawn")
 
         # If we're booting a directory image that wasn't built by root, we always make an ephemeral
index 89d71e3f557d985d11341032c0a9d54ec134697e..5a6c4a6abca9c885c0fd18179041c4aa90272a1b 100644 (file)
@@ -771,7 +771,7 @@ def finalize_initrd(config: Config) -> Iterator[Optional[Path]]:
         elif config.initrds:
             initrd = config.output_dir_or_cwd() / f"initrd-{uuid.uuid4().hex}"
             join_initrds(config.initrds, initrd)
-            stack.callback(lambda: initrd.unlink())
+            stack.callback(initrd.unlink)
             yield initrd
         else:
             yield None
index 77a88fc8859006e782073cb93ccaaae414b40fda..2cc618975be595dfb37ba18b83e805440b3ca29e 100644 (file)
@@ -67,14 +67,14 @@ def test_initrd_lvm(config: ImageConfig) -> None:
         lodev = run(
             ["losetup", "--show", "--find", "--partscan", lvm], stdout=subprocess.PIPE
         ).stdout.strip()
-        stack.callback(lambda: run(["losetup", "--detach", lodev]))
+        stack.callback(run, ["losetup", "--detach", lodev])
         run(["sfdisk", "--label", "gpt", lodev], input="type=E6D6D379-F507-44C2-A23C-238F2A3DF928 bootable")
         run(["lvm", "pvcreate", "--devicesfile", "", f"{lodev}p1"])
         run(["lvm", "pvs", "--devicesfile", ""])
         run(["lvm", "vgcreate", "--devicesfile", "", "-An", "vg_mkosi", f"{lodev}p1"])
         run(["lvm", "vgchange", "--devicesfile", "", "-ay", "vg_mkosi"])
         run(["lvm", "vgs", "--devicesfile", ""])
-        stack.callback(lambda: run(["lvm", "vgchange", "--devicesfile", "", "-an", "vg_mkosi"]))
+        stack.callback(run, ["lvm", "vgchange", "--devicesfile", "", "-an", "vg_mkosi"])
         run(["lvm", "lvcreate", "--devicesfile", "", "-An", "-l", "100%FREE", "-n", "lv0", "vg_mkosi"])
         run(["lvm", "lvs", "--devicesfile", ""])
         run(["udevadm", "wait", "--timeout=30", "/dev/vg_mkosi/lv0"])
@@ -82,7 +82,7 @@ def test_initrd_lvm(config: ImageConfig) -> None:
 
         src = Path(stack.enter_context(tempfile.TemporaryDirectory()))
         run(["systemd-dissect", "--mount", "--mkdir", Path(image.output_dir) / "image.raw", src])
-        stack.callback(lambda: run(["systemd-dissect", "--umount", "--rmdir", src]))
+        stack.callback(run, ["systemd-dissect", "--umount", "--rmdir", src])
 
         dst = Path(stack.enter_context(tempfile.TemporaryDirectory()))
         stack.enter_context(mount(Path("/dev/vg_mkosi/lv0"), dst))
@@ -165,7 +165,7 @@ def test_initrd_luks_lvm(config: ImageConfig, passphrase: Path) -> None:
         lodev = run(
             ["losetup", "--show", "--find", "--partscan", lvm], stdout=subprocess.PIPE
         ).stdout.strip()
-        stack.callback(lambda: run(["losetup", "--detach", lodev]))
+        stack.callback(run, ["losetup", "--detach", lodev])
         run(["sfdisk", "--label", "gpt", lodev], input="type=E6D6D379-F507-44C2-A23C-238F2A3DF928 bootable")
         run(
             [
@@ -179,14 +179,14 @@ def test_initrd_luks_lvm(config: ImageConfig, passphrase: Path) -> None:
             ]
         )  # fmt: skip
         run(["cryptsetup", "--key-file", passphrase, "luksOpen", f"{lodev}p1", "lvm_root"])
-        stack.callback(lambda: run(["cryptsetup", "close", "lvm_root"]))
+        stack.callback(run, ["cryptsetup", "close", "lvm_root"])
         luks_uuid = run(["cryptsetup", "luksUUID", f"{lodev}p1"], stdout=subprocess.PIPE).stdout.strip()
         run(["lvm", "pvcreate", "--devicesfile", "", "/dev/mapper/lvm_root"])
         run(["lvm", "pvs", "--devicesfile", ""])
         run(["lvm", "vgcreate", "--devicesfile", "", "-An", "vg_mkosi", "/dev/mapper/lvm_root"])
         run(["lvm", "vgchange", "--devicesfile", "", "-ay", "vg_mkosi"])
         run(["lvm", "vgs", "--devicesfile", ""])
-        stack.callback(lambda: run(["lvm", "vgchange", "--devicesfile", "", "-an", "vg_mkosi"]))
+        stack.callback(run, ["lvm", "vgchange", "--devicesfile", "", "-an", "vg_mkosi"])
         run(["lvm", "lvcreate", "--devicesfile", "", "-An", "-l", "100%FREE", "-n", "lv0", "vg_mkosi"])
         run(["lvm", "lvs", "--devicesfile", ""])
         run(["udevadm", "wait", "--timeout=30", "/dev/vg_mkosi/lv0"])
@@ -194,7 +194,7 @@ def test_initrd_luks_lvm(config: ImageConfig, passphrase: Path) -> None:
 
         src = Path(stack.enter_context(tempfile.TemporaryDirectory()))
         run(["systemd-dissect", "--mount", "--mkdir", Path(image.output_dir) / "image.raw", src])
-        stack.callback(lambda: run(["systemd-dissect", "--umount", "--rmdir", src]))
+        stack.callback(run, ["systemd-dissect", "--umount", "--rmdir", src])
 
         dst = Path(stack.enter_context(tempfile.TemporaryDirectory()))
         stack.enter_context(mount(Path("/dev/vg_mkosi/lv0"), dst))