From 02d7b68f4a2fd210724d0d85e9b1e36653bba8fe Mon Sep 17 00:00:00 2001 From: Petr Stodulka Date: Tue, 14 May 2024 15:24:43 +0200 Subject: [PATCH] Fix E0606 errors reported by pylint E0606 -> possibly-used-before-assignement Note that in case of checktargetrepos actor we are introducing https://red.ht/upgrading-rhel9-to-rhel10-main-official-doc for IPU 9 -> 10. However, this shortened URL must be defined yet later. --- .../actors/checktargetrepos/libraries/checktargetrepos.py | 3 +++ .../tests/unit_test_upgradeinitramfsgenerator.py | 1 + .../common/actors/scantargetiso/tests/test_scan_target_iso.py | 1 + .../tests/unit_test_selinuxcontentscanner.py | 2 ++ .../selinux/selinuxprepare/tests/unit_test_selinuxprepare.py | 1 + repos/system_upgrade/common/libraries/tests/test_grub.py | 3 +++ repos/system_upgrade/common/libraries/tests/test_mdraid.py | 2 ++ 7 files changed, 13 insertions(+) diff --git a/repos/system_upgrade/common/actors/checktargetrepos/libraries/checktargetrepos.py b/repos/system_upgrade/common/actors/checktargetrepos/libraries/checktargetrepos.py index 6d5a2f655f..0a545784b5 100644 --- a/repos/system_upgrade/common/actors/checktargetrepos/libraries/checktargetrepos.py +++ b/repos/system_upgrade/common/actors/checktargetrepos/libraries/checktargetrepos.py @@ -33,6 +33,9 @@ def process(): ipu_doc_url = 'https://red.ht/upgrading-rhel7-to-rhel8-main-official-doc' elif target_major_version == '9': ipu_doc_url = 'https://red.ht/upgrading-rhel8-to-rhel9-main-official-doc' + else: + ipu_doc_url = 'https://red.ht/upgrading-rhel9-to-rhel10-main-official-doc' + rhui_info = next(api.consume(RHUIInfo), None) diff --git a/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/tests/unit_test_upgradeinitramfsgenerator.py b/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/tests/unit_test_upgradeinitramfsgenerator.py index 8068e177aa..7397b82b93 100644 --- a/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/tests/unit_test_upgradeinitramfsgenerator.py +++ b/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/tests/unit_test_upgradeinitramfsgenerator.py @@ -354,6 +354,7 @@ def mock_context_path_exists(path): module_class = None copy_fn = None + dst_path = None if kind == 'dracut': module_class = DracutModule copy_fn = upgradeinitramfsgenerator.copy_dracut_modules diff --git a/repos/system_upgrade/common/actors/scantargetiso/tests/test_scan_target_iso.py b/repos/system_upgrade/common/actors/scantargetiso/tests/test_scan_target_iso.py index 4dd0a1251e..8e235c6d3d 100644 --- a/repos/system_upgrade/common/actors/scantargetiso/tests/test_scan_target_iso.py +++ b/repos/system_upgrade/common/actors/scantargetiso/tests/test_scan_target_iso.py @@ -201,6 +201,7 @@ def mocked_os_listdir(path): produced_custom_repo_msgs = [] target_iso_msg = None + target_iso = None for produced_msg in produced_msgs: if isinstance(produced_msg, CustomTargetRepository): produced_custom_repo_msgs.append(produced_msg) diff --git a/repos/system_upgrade/common/actors/selinux/selinuxcontentscanner/tests/unit_test_selinuxcontentscanner.py b/repos/system_upgrade/common/actors/selinux/selinuxcontentscanner/tests/unit_test_selinuxcontentscanner.py index 1837c24537..830eeac592 100644 --- a/repos/system_upgrade/common/actors/selinux/selinuxcontentscanner/tests/unit_test_selinuxcontentscanner.py +++ b/repos/system_upgrade/common/actors/selinux/selinuxcontentscanner/tests/unit_test_selinuxcontentscanner.py @@ -33,6 +33,8 @@ def __call__(self, args, split=True): "port -a -t http_port_t -p udp 81", "fcontext -a -f a -t httpd_sys_content_t '/web(/.*)?'", "fcontext -a -f a -t cgdcbxd_exec_t '/ganesha(/.*)?'"] + else: + assert False, 'run_mocked: Called unexpected cmd not covered by test: {}'.format(self.args) return {'stdout': stdout} diff --git a/repos/system_upgrade/common/actors/selinux/selinuxprepare/tests/unit_test_selinuxprepare.py b/repos/system_upgrade/common/actors/selinux/selinuxprepare/tests/unit_test_selinuxprepare.py index 7d975dda98..c1ad06c573 100644 --- a/repos/system_upgrade/common/actors/selinux/selinuxprepare/tests/unit_test_selinuxprepare.py +++ b/repos/system_upgrade/common/actors/selinux/selinuxprepare/tests/unit_test_selinuxprepare.py @@ -24,6 +24,7 @@ def __call__(self, args, split=True): self.removed_modules.add(self.args[idx + 1]) else: self.non_semodule_calls += 1 + stdout = [] return {'stdout': stdout} diff --git a/repos/system_upgrade/common/libraries/tests/test_grub.py b/repos/system_upgrade/common/libraries/tests/test_grub.py index 5a4f3f634a..6f13538cb2 100644 --- a/repos/system_upgrade/common/libraries/tests/test_grub.py +++ b/repos/system_upgrade/common/libraries/tests/test_grub.py @@ -40,6 +40,7 @@ def __init__(self, raise_err=False, boot_on_raid=False): def __call__(self, args, encoding=None): self.called += 1 self.args = args + stdout = '' if self.raise_err: raise_call_error(args) @@ -50,6 +51,8 @@ def __call__(self, args, encoding=None): stdout = BOOT_DEVICE elif self.args[:-1] == ['lsblk', '-spnlo', 'name']: stdout = self.args[-1][:-1] + else: + assert False, 'RunMockedError: Called unexpected cmd not covered by test: {}'.format(self.args) return {'stdout': stdout} diff --git a/repos/system_upgrade/common/libraries/tests/test_mdraid.py b/repos/system_upgrade/common/libraries/tests/test_mdraid.py index cb7c1059d1..d536beecea 100644 --- a/repos/system_upgrade/common/libraries/tests/test_mdraid.py +++ b/repos/system_upgrade/common/libraries/tests/test_mdraid.py @@ -42,6 +42,8 @@ def __call__(self, args, encoding=None): stdout = 'ARRAY /dev/md0 level=raid1 num-devices=2 metadata=1.2 name=localhost.localdomain:0 UUID=c4acea6e:d56e1598:91822e3f:fb26832c\n devices=/dev/sda1,/dev/sdb1' # noqa: E501; pylint: disable=line-too-long elif self.args == ['mdadm', '--detail', '--verbose', '--brief', NOT_MD_DEVICE]: stdout = 'mdadm: /dev/sda does not appear to be an md device' + else: + assert False, 'RunMockedError: Called unexpected cmd not covered by test: {}'.format(self.args) return {'stdout': stdout}