leapp-repository/0038-Fix-E0606-errors-reported-by-pylint.patch
Petr Stodulka b4aed63dad CTC1 candidate 2 (Release for 8.10/9.5)
- Enable new upgrade path RHEL 8.10 -> 9.5
- Minor updates in reports
- Add information about leapp invocation to leapp.db
- Resolves: RHEL-27847
2024-05-30 15:20:28 +02:00

120 lines
6.4 KiB
Diff

From 96346a5400a6e9741566e5070024a7918a6a9323 Mon Sep 17 00:00:00 2001
From: Petr Stodulka <pstodulk@redhat.com>
Date: Tue, 14 May 2024 15:24:43 +0200
Subject: [PATCH 38/49] 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 | 2 ++
.../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, 12 insertions(+)
diff --git a/repos/system_upgrade/common/actors/checktargetrepos/libraries/checktargetrepos.py b/repos/system_upgrade/common/actors/checktargetrepos/libraries/checktargetrepos.py
index 6d5a2f65..c286ed4f 100644
--- a/repos/system_upgrade/common/actors/checktargetrepos/libraries/checktargetrepos.py
+++ b/repos/system_upgrade/common/actors/checktargetrepos/libraries/checktargetrepos.py
@@ -33,6 +33,8 @@ 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 8068e177..7397b82b 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 test_copy_modules_fail(monkeypatch, kind):
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 4dd0a125..8e235c6d 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 test_iso_repository_detection(monkeypatch, repodirs_in_iso, expected_repoids
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 1837c245..830eeac5 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 @@ class run_mocked(object):
"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 7d975dda..c1ad06c5 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 @@ class run_mocked(object):
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 5a4f3f63..6f13538c 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 @@ class RunMocked(object):
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 @@ class RunMocked(object):
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 cb7c1059..d536beec 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 @@ class RunMocked(object):
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}
--
2.44.0