From 1e8f7fdf15c84a185920f46a4928120d5e36e41b Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Wed, 15 May 2024 13:49:33 -0700 Subject: [PATCH] boot-utils: Address new pylint possibly-used-before-assignment warnings boot-qemu.py:148:32: E0606: Possibly using variable 'decomp_cmd' before assignment (possibly-used-before-assignment) utils.py:215:24: E0606: Possibly using variable 'gh_json_rel' before assignment (possibly-used-before-assignment) Signed-off-by: Nathan Chancellor --- boot-qemu.py | 3 +++ utils.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/boot-qemu.py b/boot-qemu.py index 2b07c1b..eef5cd0 100755 --- a/boot-qemu.py +++ b/boot-qemu.py @@ -125,6 +125,9 @@ def _get_kernel_ver_tuple(self, decomp_prog): utils.check_cmd(decomp_prog) if decomp_prog in ('gzip', ): decomp_cmd = [decomp_prog, '-c', '-d', self.kernel] + else: + raise RuntimeError( + f"Unsupported decompression program ('{decomp_prog}')?") decomp = subprocess.run(decomp_cmd, capture_output=True, check=True) utils.check_cmd('strings') diff --git a/utils.py b/utils.py index 51d7419..6ca0846 100755 --- a/utils.py +++ b/utils.py @@ -212,6 +212,9 @@ def prepare_initrd(architecture, rootfs_format='cpio', gh_json_file=None): # Download the ramdisk if it is not already downloaded if not src.exists(): + # gh_json_rel cannot be unset when used here because the elif condition + # above is the same as this one, which causes the script to exit. + # pylint: disable-next=possibly-used-before-assignment download_initrd(gh_json_rel, src) # If it is already downloaded, check that it is up to date and download # an update only if necessary.