]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Drop unnecessary parentheses around conditionals 2317/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 Jan 2024 09:39:48 +0000 (10:39 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 Jan 2024 09:39:48 +0000 (10:39 +0100)
mkosi/__init__.py
mkosi/config.py
mkosi/qemu.py
mkosi/run.py
mkosi/util.py

index 07e6c3184429241ddf4ae10acf6c8a744b2395f8..de3350a2d2be4f3f88296edfb9d19ad0e53d2704 100644 (file)
@@ -2650,7 +2650,7 @@ def make_disk(
         defaults = context.workspace / "repart-definitions"
         if not defaults.exists():
             defaults.mkdir()
-            if (arch := context.config.architecture.to_efi()):
+            if arch := context.config.architecture.to_efi():
                 bootloader = context.root / f"efi/EFI/BOOT/BOOT{arch.upper()}.EFI"
             else:
                 bootloader = None
@@ -3432,7 +3432,7 @@ def run_clean(args: Args, config: Config) -> None:
         remove_build_cache = args.force > 1
         remove_package_cache = args.force > 2
 
-    if (outputs := list(config.output_dir_or_cwd().glob(f"{config.output}*"))):
+    if outputs := list(config.output_dir_or_cwd().glob(f"{config.output}*")):
         with complete_step(f"Removing output files of {config.name()} image…"):
             rmtree(*outputs)
 
index 3e0a4b200ed31e4e6e76636ecf23b75b2b4e7e09..18b79560af029170b6ee74da0a7243a1f45c067e 100644 (file)
@@ -2866,7 +2866,7 @@ def parse_config(argv: Sequence[str] = ()) -> tuple[Args, tuple[Config, ...]]:
             if not v:
                 die("Match value cannot be empty")
 
-            if (s := SETTINGS_LOOKUP_BY_NAME.get(k)):
+            if s := SETTINGS_LOOKUP_BY_NAME.get(k):
                 if not s.match:
                     die(f"{k} cannot be used in [Match]")
 
@@ -2881,7 +2881,7 @@ def parse_config(argv: Sequence[str] = ()) -> tuple[Args, tuple[Config, ...]]:
                 else:
                     result = s.match(v, getattr(namespace, s.dest))
 
-            elif (m := MATCH_LOOKUP.get(k)):
+            elif m := MATCH_LOOKUP.get(k):
                 result = m.match(v)
             else:
                 die(f"{k} cannot be used in [Match]")
index bc641d0c2784de6676b53fd031cccc6aea85079b..6d3066880c4e18c86e3bf79889ab9bed527dcf24 100644 (file)
@@ -485,7 +485,7 @@ def run_qemu(args: Args, config: Config) -> None:
     ):
         die(f"{config.output_format} images cannot be booted with the '{config.qemu_firmware}' firmware")
 
-    if (config.runtime_trees and config.qemu_firmware == QemuFirmware.bios):
+    if config.runtime_trees and config.qemu_firmware == QemuFirmware.bios:
         die("RuntimeTrees= cannot be used when booting in BIOS firmware")
 
     if config.qemu_kvm == ConfigFeature.enabled and not config.architecture.is_native():
@@ -503,7 +503,7 @@ def run_qemu(args: Args, config: Config) -> None:
 
     have_kvm = ((qemu_version(config) < QEMU_KVM_DEVICE_VERSION and QemuDeviceNode.kvm.available()) or
                 (qemu_version(config) >= QEMU_KVM_DEVICE_VERSION and QemuDeviceNode.kvm in qemu_device_fds))
-    if (config.qemu_kvm == ConfigFeature.enabled and not have_kvm):
+    if config.qemu_kvm == ConfigFeature.enabled and not have_kvm:
         die("KVM acceleration requested but cannot access /dev/kvm")
 
     if config.qemu_vsock == ConfigFeature.enabled and QemuDeviceNode.vhost_vsock not in qemu_device_fds:
index c72ed4eca9302156aa092cc376fe58e59eac3739..2f943d22d5344527fbaad06434117d97b14d07af 100644 (file)
@@ -418,7 +418,7 @@ def find_binary(*names: PathString, root: Path = Path("/")) -> Optional[Path]:
         elif "/" in str(name):
             name = root / name
 
-        if (binary := shutil.which(name, path=path)):
+        if binary := shutil.which(name, path=path):
             if root != Path("/") and not Path(binary).is_relative_to(root):
                 return Path(binary)
             else:
index 102747aea46d6587a63afa466c04f450f5121d05..454d5f09600f18f41bb145ea069c5ae860045e2f 100644 (file)
@@ -41,7 +41,7 @@ def read_env_file(path: Path) -> Iterator[tuple[str, str]]:
             line = line.rstrip()
             if not line or line.startswith("#"):
                 continue
-            if (m := re.match(r"([A-Z][A-Z_0-9]+)=(.*)", line)):
+            if m := re.match(r"([A-Z][A-Z_0-9]+)=(.*)", line):
                 name, val = m.groups()
                 if val and val[0] in "\"'":
                     val = ast.literal_eval(val)