forked from rpms/leapp-repository
614 lines
28 KiB
Diff
614 lines
28 KiB
Diff
From 81b24a657037ceffc3959abb4231a19352ca9a82 Mon Sep 17 00:00:00 2001
|
|
From: Tomas Fratrik <tfratrik@redhat.com>
|
|
Date: Mon, 18 Aug 2025 14:42:15 +0200
|
|
Subject: [PATCH 40/55] pylint: enable bad-option-value
|
|
|
|
This pylint warning triggers when you try to disable a pylint check that is unknown or obsolete. Enabling this rule caused such warnings to appear, so the corresponding disables needed to be removed:
|
|
* no-absolute-import -> Only relevant for Python 2. Python 3 uses absolute imports by default.
|
|
* no-init -> Obsolete: __init__ method checks have changed, this option no longer exists.
|
|
* bad-continuation -> Superseded by modern pylint formatting checks.
|
|
* no-self-use -> Checks whether a method could be a function.
|
|
* relative-import -> Python 3 discourages relative imports differently.
|
|
|
|
Jira: RHELMISC-16038
|
|
---
|
|
.pylintrc | 8 +----
|
|
commands/upgrade/breadcrumbs.py | 9 +++--
|
|
.../checkmemory/libraries/checkmemory.py | 4 +--
|
|
.../tests/test_enablerhsmtargetrepos.py | 3 +-
|
|
.../tests/test_mount_unit_generation.py | 3 +-
|
|
.../libraries/upgradeinitramfsgenerator.py | 2 +-
|
|
.../unit_test_upgradeinitramfsgenerator.py | 2 +-
|
|
.../tests/test_kernelcmdlineconfig.py | 4 +--
|
|
.../opensshpermitrootlogincheck/actor.py | 6 ++--
|
|
.../actors/persistentnetnamesdisable/actor.py | 6 ++--
|
|
.../libraries/scankernel.py | 2 +-
|
|
.../tests/unit_test_targetuserspacecreator.py | 3 +-
|
|
.../tests/test_trustedgpgkeys.py | 2 +-
|
|
.../common/files/rhel_upgrade.py | 9 +++--
|
|
.../common/libraries/dnfplugin.py | 3 +-
|
|
repos/system_upgrade/common/libraries/grub.py | 4 +--
|
|
.../common/libraries/mounting.py | 3 +-
|
|
.../common/libraries/overlaygen.py | 35 ++++++++++++-------
|
|
.../common/libraries/tests/test_distro.py | 3 +-
|
|
.../common/libraries/tests/test_grub.py | 2 +-
|
|
.../common/libraries/tests/test_rhsm.py | 6 ++--
|
|
.../common/libraries/testutils.py | 2 +-
|
|
.../checkvdo/tests/unit_test_checkvdo.py | 6 ++--
|
|
.../actors/nisscanner/libraries/nisscan.py | 6 ++--
|
|
.../libraries/opensslconfigcheck.py | 3 +-
|
|
25 files changed, 81 insertions(+), 55 deletions(-)
|
|
|
|
diff --git a/.pylintrc b/.pylintrc
|
|
index 7a373e3d..0cba1129 100644
|
|
--- a/.pylintrc
|
|
+++ b/.pylintrc
|
|
@@ -9,23 +9,19 @@ disable=
|
|
raising-bad-type,
|
|
redundant-keyword-arg, # it's one or the other, this one is not so bad at all
|
|
# "W" Warnings for stylistic problems or minor programming issues
|
|
- no-absolute-import,
|
|
arguments-differ,
|
|
cell-var-from-loop,
|
|
fixme,
|
|
lost-exception,
|
|
- no-init,
|
|
pointless-string-statement,
|
|
protected-access,
|
|
redefined-outer-name,
|
|
- relative-import,
|
|
undefined-loop-variable,
|
|
unsubscriptable-object,
|
|
unused-argument,
|
|
unused-import,
|
|
unspecified-encoding,
|
|
# "C" Coding convention violations
|
|
- bad-continuation,
|
|
missing-docstring,
|
|
wrong-import-order,
|
|
use-maxsplit-arg,
|
|
@@ -33,7 +29,6 @@ disable=
|
|
consider-using-enumerate,
|
|
# "R" Refactor recommendations
|
|
duplicate-code,
|
|
- no-self-use,
|
|
too-few-public-methods,
|
|
too-many-branches,
|
|
too-many-locals,
|
|
@@ -42,10 +37,9 @@ disable=
|
|
use-list-literal,
|
|
use-dict-literal,
|
|
too-many-lines, # we do not want to take care about that one
|
|
- too-many-positional-arguments, # we cannot set yet max-possitional-arguments unfortunately
|
|
+ too-many-positional-arguments,
|
|
# new for python3 version of pylint
|
|
unnecessary-pass,
|
|
- bad-option-value, # python 2 doesn't have import-outside-toplevel, but in some case we need to import outside toplevel
|
|
super-with-arguments, # required in python 2
|
|
raise-missing-from, # no 'raise from' in python 2
|
|
use-a-generator, # cannot be modified because of Python2 support
|
|
diff --git a/commands/upgrade/breadcrumbs.py b/commands/upgrade/breadcrumbs.py
|
|
index 1a90c143..95a551c3 100644
|
|
--- a/commands/upgrade/breadcrumbs.py
|
|
+++ b/commands/upgrade/breadcrumbs.py
|
|
@@ -80,7 +80,8 @@ class _BreadCrumbs:
|
|
# even though it shouldn't though, just ignore it
|
|
pass
|
|
|
|
- def _commit_rhsm_facts(self):
|
|
+ @staticmethod
|
|
+ def _commit_rhsm_facts():
|
|
if runs_in_container():
|
|
return
|
|
cmd = ['/usr/sbin/subscription-manager', 'facts', '--update']
|
|
@@ -122,7 +123,8 @@ class _BreadCrumbs:
|
|
except OSError:
|
|
sys.stderr.write('WARNING: Could not write to /etc/migration-results\n')
|
|
|
|
- def _get_packages(self):
|
|
+ @staticmethod
|
|
+ def _get_packages():
|
|
cmd = ['/bin/bash', '-c', 'rpm -qa --queryformat="%{nevra} %{SIGPGP:pgpsig}\n" | grep -Ee "leapp|snactor"']
|
|
res = _call(cmd, lambda x, y: None, lambda x, y: None)
|
|
if res.get('exit_code', None) == 0:
|
|
@@ -131,7 +133,8 @@ class _BreadCrumbs:
|
|
for t in [line.strip().split(' ', 1) for line in res['stdout'].split('\n') if line.strip()]]
|
|
return []
|
|
|
|
- def _verify_leapp_pkgs(self):
|
|
+ @staticmethod
|
|
+ def _verify_leapp_pkgs():
|
|
if not os.environ.get('LEAPP_IPU_IN_PROGRESS'):
|
|
return []
|
|
upg_path = os.environ.get('LEAPP_IPU_IN_PROGRESS').split('to')
|
|
diff --git a/repos/system_upgrade/common/actors/checkmemory/libraries/checkmemory.py b/repos/system_upgrade/common/actors/checkmemory/libraries/checkmemory.py
|
|
index 808c9662..040b404b 100644
|
|
--- a/repos/system_upgrade/common/actors/checkmemory/libraries/checkmemory.py
|
|
+++ b/repos/system_upgrade/common/actors/checkmemory/libraries/checkmemory.py
|
|
@@ -34,8 +34,8 @@ def process():
|
|
if minimum_req_error:
|
|
title = 'Minimum memory requirements for RHEL {} are not met'.format(version.get_target_major_version())
|
|
summary = 'Memory detected: {} MiB, required: {} MiB'.format(
|
|
- int(minimum_req_error['detected'] / 1024), # noqa: W1619; pylint: disable=old-division
|
|
- int(minimum_req_error['minimal_req'] / 1024), # noqa: W1619; pylint: disable=old-division
|
|
+ int(minimum_req_error['detected'] / 1024),
|
|
+ int(minimum_req_error['minimal_req'] / 1024),
|
|
)
|
|
reporting.create_report([
|
|
reporting.Title(title),
|
|
diff --git a/repos/system_upgrade/common/actors/enablerhsmtargetrepos/tests/test_enablerhsmtargetrepos.py b/repos/system_upgrade/common/actors/enablerhsmtargetrepos/tests/test_enablerhsmtargetrepos.py
|
|
index f7b3f34a..dba38fff 100644
|
|
--- a/repos/system_upgrade/common/actors/enablerhsmtargetrepos/tests/test_enablerhsmtargetrepos.py
|
|
+++ b/repos/system_upgrade/common/actors/enablerhsmtargetrepos/tests/test_enablerhsmtargetrepos.py
|
|
@@ -17,7 +17,8 @@ def not_isolated_actions(raise_err=False):
|
|
def __init__(self, base_dir=None):
|
|
pass
|
|
|
|
- def call(self, cmd, **kwargs):
|
|
+ @staticmethod
|
|
+ def call(cmd, **kwargs):
|
|
commands_called.append((cmd, kwargs))
|
|
if raise_err:
|
|
raise_call_error()
|
|
diff --git a/repos/system_upgrade/common/actors/initramfs/mount_units_generator/tests/test_mount_unit_generation.py b/repos/system_upgrade/common/actors/initramfs/mount_units_generator/tests/test_mount_unit_generation.py
|
|
index 9d75a31d..8849ada9 100644
|
|
--- a/repos/system_upgrade/common/actors/initramfs/mount_units_generator/tests/test_mount_unit_generation.py
|
|
+++ b/repos/system_upgrade/common/actors/initramfs/mount_units_generator/tests/test_mount_unit_generation.py
|
|
@@ -249,7 +249,8 @@ def test_copy_units_mixed_content(monkeypatch):
|
|
def __init__(self):
|
|
self.base_dir = '/container'
|
|
|
|
- def full_path(self, path):
|
|
+ @staticmethod
|
|
+ def full_path(path):
|
|
return os.path.join('/container', path.lstrip('/'))
|
|
|
|
mock_container = MockedContainerContext()
|
|
diff --git a/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/libraries/upgradeinitramfsgenerator.py b/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/libraries/upgradeinitramfsgenerator.py
|
|
index 3ad92167..f7e4a8af 100644
|
|
--- a/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/libraries/upgradeinitramfsgenerator.py
|
|
+++ b/repos/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/libraries/upgradeinitramfsgenerator.py
|
|
@@ -271,7 +271,7 @@ def _get_fspace(path, convert_to_mibs=False, coefficient=1):
|
|
coefficient = min(coefficient, 1)
|
|
fspace_bytes = int(stat.f_frsize * stat.f_bavail * coefficient)
|
|
if convert_to_mibs:
|
|
- return int(fspace_bytes / 1024 / 1024) # noqa: W1619; pylint: disable=old-division
|
|
+ return int(fspace_bytes / 1024 / 1024)
|
|
return fspace_bytes
|
|
|
|
|
|
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 185cd4f0..b96bf79f 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
|
|
@@ -257,7 +257,7 @@ class MockedGetFspace:
|
|
def __call__(self, dummy_path, convert_to_mibs=False):
|
|
if not convert_to_mibs:
|
|
return self.space
|
|
- return int(self.space / 1024 / 1024) # noqa: W1619; pylint: disable=old-division
|
|
+ return int(self.space / 1024 / 1024)
|
|
|
|
|
|
@pytest.mark.parametrize('input_msgs,dracut_modules,kernel_modules', [
|
|
diff --git a/repos/system_upgrade/common/actors/kernelcmdlineconfig/tests/test_kernelcmdlineconfig.py b/repos/system_upgrade/common/actors/kernelcmdlineconfig/tests/test_kernelcmdlineconfig.py
|
|
index b7e51833..5b35bcd3 100644
|
|
--- a/repos/system_upgrade/common/actors/kernelcmdlineconfig/tests/test_kernelcmdlineconfig.py
|
|
+++ b/repos/system_upgrade/common/actors/kernelcmdlineconfig/tests/test_kernelcmdlineconfig.py
|
|
@@ -15,7 +15,7 @@ from leapp.models import InstalledTargetKernelInfo, KernelCmdlineArg, TargetKern
|
|
|
|
TARGET_KERNEL_NEVRA = 'kernel-core-1.2.3-4.x86_64.el8.x64_64'
|
|
|
|
-# pylint: disable=E501
|
|
+# pylint: disable=line-too-long
|
|
SAMPLE_KERNEL_ARGS = ('ro rootflags=subvol=root'
|
|
' resume=/dev/mapper/luks-2c0df999-81ec-4a35-a1f9-b93afee8c6ad'
|
|
' rd.luks.uuid=luks-90a6412f-c588-46ca-9118-5aca35943d25'
|
|
@@ -31,7 +31,7 @@ title="Fedora Linux (6.5.13-100.fc37.x86_64) 37 (Thirty Seven)"
|
|
id="a3018267cdd8451db7c77bb3e5b1403d-6.5.13-100.fc37.x86_64"
|
|
""" # noqa: E501
|
|
SAMPLE_GRUBBY_INFO_OUTPUT = TEMPLATE_GRUBBY_INFO_OUTPUT.format(SAMPLE_KERNEL_ARGS, SAMPLE_KERNEL_ROOT)
|
|
-# pylint: enable=E501
|
|
+# pylint: enable=line-too-long
|
|
|
|
|
|
class MockedRun:
|
|
diff --git a/repos/system_upgrade/common/actors/opensshpermitrootlogincheck/actor.py b/repos/system_upgrade/common/actors/opensshpermitrootlogincheck/actor.py
|
|
index 9c1a421c..98d329ab 100644
|
|
--- a/repos/system_upgrade/common/actors/opensshpermitrootlogincheck/actor.py
|
|
+++ b/repos/system_upgrade/common/actors/opensshpermitrootlogincheck/actor.py
|
|
@@ -55,7 +55,8 @@ class OpenSshPermitRootLoginCheck(Actor):
|
|
else:
|
|
api.current_logger().warning('Unknown source major version: {}'.format(get_source_major_version()))
|
|
|
|
- def process7to8(self, config):
|
|
+ @staticmethod
|
|
+ def process7to8(config):
|
|
# when the config was not modified, we can pass this check and let the
|
|
# rpm handle the configuration file update
|
|
if not config.modified:
|
|
@@ -112,7 +113,8 @@ class OpenSshPermitRootLoginCheck(Actor):
|
|
reporting.Groups([reporting.Groups.INHIBITOR])
|
|
] + COMMON_RESOURCES)
|
|
|
|
- def process8to9(self, config):
|
|
+ @staticmethod
|
|
+ def process8to9(config):
|
|
# RHEL8 default sshd configuration file is not modified: It will get replaced by rpm and
|
|
# root will no longer be able to connect through ssh. This will probably result in many
|
|
# false positives so it will have to be waived a lot
|
|
diff --git a/repos/system_upgrade/common/actors/persistentnetnamesdisable/actor.py b/repos/system_upgrade/common/actors/persistentnetnamesdisable/actor.py
|
|
index 1add3588..b0182982 100644
|
|
--- a/repos/system_upgrade/common/actors/persistentnetnamesdisable/actor.py
|
|
+++ b/repos/system_upgrade/common/actors/persistentnetnamesdisable/actor.py
|
|
@@ -18,7 +18,8 @@ class PersistentNetNamesDisable(Actor):
|
|
produces = (KernelCmdlineArg, Report)
|
|
tags = (FactsPhaseTag, IPUWorkflowTag)
|
|
|
|
- def ethX_count(self, interfaces):
|
|
+ @staticmethod
|
|
+ def ethX_count(interfaces):
|
|
ethX = re.compile('eth[0-9]+')
|
|
count = 0
|
|
|
|
@@ -27,7 +28,8 @@ class PersistentNetNamesDisable(Actor):
|
|
count = count + 1
|
|
return count
|
|
|
|
- def single_eth0(self, interfaces):
|
|
+ @staticmethod
|
|
+ def single_eth0(interfaces):
|
|
return len(interfaces) == 1 and interfaces[0].name == 'eth0'
|
|
|
|
def disable_persistent_naming(self):
|
|
diff --git a/repos/system_upgrade/common/actors/scaninstalledtargetkernelversion/libraries/scankernel.py b/repos/system_upgrade/common/actors/scaninstalledtargetkernelversion/libraries/scankernel.py
|
|
index c1cc69ee..35683cca 100644
|
|
--- a/repos/system_upgrade/common/actors/scaninstalledtargetkernelversion/libraries/scankernel.py
|
|
+++ b/repos/system_upgrade/common/actors/scaninstalledtargetkernelversion/libraries/scankernel.py
|
|
@@ -70,7 +70,7 @@ def get_boot_files_provided_by_kernel_pkg(kernel_nevra):
|
|
|
|
@suppress_deprecation(InstalledTargetKernelVersion)
|
|
def process():
|
|
- # pylint: disable=no-else-return - false positive
|
|
+ # pylint: disable=no-else-return # false positive
|
|
# TODO: should we take care about stuff of kernel-rt and kernel in the same
|
|
# time when both are present? or just one? currently, handle only one
|
|
# of these during the upgrade. kernel-rt has higher prio when original sys
|
|
diff --git a/repos/system_upgrade/common/actors/targetuserspacecreator/tests/unit_test_targetuserspacecreator.py b/repos/system_upgrade/common/actors/targetuserspacecreator/tests/unit_test_targetuserspacecreator.py
|
|
index 1e5b87b0..bb17d89a 100644
|
|
--- a/repos/system_upgrade/common/actors/targetuserspacecreator/tests/unit_test_targetuserspacecreator.py
|
|
+++ b/repos/system_upgrade/common/actors/targetuserspacecreator/tests/unit_test_targetuserspacecreator.py
|
|
@@ -50,7 +50,8 @@ class MockedMountingBase:
|
|
def __call__(self, **dummy_kwarg):
|
|
yield self
|
|
|
|
- def call(self, *args, **kwargs):
|
|
+ @staticmethod
|
|
+ def call(*args, **kwargs):
|
|
return {'stdout': ''}
|
|
|
|
def nspawn(self):
|
|
diff --git a/repos/system_upgrade/common/actors/trustedgpgkeysscanner/tests/test_trustedgpgkeys.py b/repos/system_upgrade/common/actors/trustedgpgkeysscanner/tests/test_trustedgpgkeys.py
|
|
index 7497c2a9..b8229d00 100644
|
|
--- a/repos/system_upgrade/common/actors/trustedgpgkeysscanner/tests/test_trustedgpgkeys.py
|
|
+++ b/repos/system_upgrade/common/actors/trustedgpgkeysscanner/tests/test_trustedgpgkeys.py
|
|
@@ -40,7 +40,7 @@ class MockedGetGpgFromFile:
|
|
self._data[fname] = fps
|
|
|
|
def get_files(self):
|
|
- return self._data.keys() # noqa: W1655; pylint: disable=dict-keys-not-iterating
|
|
+ return self._data.keys()
|
|
|
|
def __call__(self, fname):
|
|
return self._data.get(fname, [])
|
|
diff --git a/repos/system_upgrade/common/files/rhel_upgrade.py b/repos/system_upgrade/common/files/rhel_upgrade.py
|
|
index 4f76a61d..a5d7045b 100644
|
|
--- a/repos/system_upgrade/common/files/rhel_upgrade.py
|
|
+++ b/repos/system_upgrade/common/files/rhel_upgrade.py
|
|
@@ -49,7 +49,8 @@ class RhelUpgradeCommand(dnf.cli.Command):
|
|
metavar="[%s]" % "|".join(CMDS))
|
|
parser.add_argument('filename')
|
|
|
|
- def _process_entities(self, entities, op, entity_name):
|
|
+ @staticmethod
|
|
+ def _process_entities(entities, op, entity_name):
|
|
"""
|
|
Adds list of packages for given operation to the transaction
|
|
"""
|
|
@@ -73,7 +74,8 @@ class RhelUpgradeCommand(dnf.cli.Command):
|
|
with open(self.opts.filename, 'w+') as fo:
|
|
json.dump(self.plugin_data, fo, sort_keys=True, indent=2)
|
|
|
|
- def _read_aws_region(self, repo):
|
|
+ @staticmethod
|
|
+ def _read_aws_region(repo):
|
|
region = None
|
|
if repo.baseurl:
|
|
# baseurl is tuple (changed by Amazon-id plugin)
|
|
@@ -86,7 +88,8 @@ class RhelUpgradeCommand(dnf.cli.Command):
|
|
sys.exit(1)
|
|
return region
|
|
|
|
- def _fix_rhui_url(self, repo, region):
|
|
+ @staticmethod
|
|
+ def _fix_rhui_url(repo, region):
|
|
if repo.baseurl:
|
|
repo.baseurl = tuple(
|
|
url.replace('REGION', region, 1) for url in repo.baseurl
|
|
diff --git a/repos/system_upgrade/common/libraries/dnfplugin.py b/repos/system_upgrade/common/libraries/dnfplugin.py
|
|
index 4f0c3a99..1af52dc5 100644
|
|
--- a/repos/system_upgrade/common/libraries/dnfplugin.py
|
|
+++ b/repos/system_upgrade/common/libraries/dnfplugin.py
|
|
@@ -461,9 +461,10 @@ def perform_transaction_install(target_userspace_info, storage_info, used_repos,
|
|
|
|
@contextlib.contextmanager
|
|
def _prepare_perform(used_repos, target_userspace_info, xfs_info, storage_info, target_iso=None):
|
|
- # noqa: W0135; pylint: disable=contextmanager-generator-missing-cleanup
|
|
+ # noqa: W0135; pylint: disable=bad-option-value,contextmanager-generator-missing-cleanup
|
|
# NOTE(pstodulk): the pylint check is not valid in this case - finally is covered
|
|
# implicitly
|
|
+ # noqa: W0135
|
|
reserve_space = overlaygen.get_recommended_leapp_free_space(target_userspace_info.path)
|
|
with _prepare_transaction(used_repos=used_repos,
|
|
target_userspace_info=target_userspace_info
|
|
diff --git a/repos/system_upgrade/common/libraries/grub.py b/repos/system_upgrade/common/libraries/grub.py
|
|
index 71432371..77679d01 100644
|
|
--- a/repos/system_upgrade/common/libraries/grub.py
|
|
+++ b/repos/system_upgrade/common/libraries/grub.py
|
|
@@ -34,7 +34,6 @@ class EFIBootLoaderEntry:
|
|
"""
|
|
Representation of an UEFI boot loader entry.
|
|
"""
|
|
- # pylint: disable=eq-without-hash
|
|
|
|
def __init__(self, boot_number, label, active, efi_bin_source):
|
|
self.boot_number = boot_number
|
|
@@ -163,7 +162,8 @@ class EFIBootInfo:
|
|
# it's not expected that no entry exists
|
|
raise StopActorExecution('UEFI: Unable to detect any UEFI bootloader entry.')
|
|
|
|
- def _parse_key_value(self, bootmgr_output, key):
|
|
+ @staticmethod
|
|
+ def _parse_key_value(bootmgr_output, key):
|
|
# e.g.: <key>: <value>
|
|
for line in bootmgr_output.splitlines():
|
|
if line.startswith(key + ':'):
|
|
diff --git a/repos/system_upgrade/common/libraries/mounting.py b/repos/system_upgrade/common/libraries/mounting.py
|
|
index 4e99e31e..ae3885cf 100644
|
|
--- a/repos/system_upgrade/common/libraries/mounting.py
|
|
+++ b/repos/system_upgrade/common/libraries/mounting.py
|
|
@@ -66,7 +66,8 @@ class IsolationType:
|
|
""" Release the isolation context """
|
|
pass
|
|
|
|
- def make_command(self, cmd):
|
|
+ @staticmethod
|
|
+ def make_command(cmd):
|
|
""" Transform the given command to the isolated environment """
|
|
return cmd
|
|
|
|
diff --git a/repos/system_upgrade/common/libraries/overlaygen.py b/repos/system_upgrade/common/libraries/overlaygen.py
|
|
index a048af2b..83dc33b8 100644
|
|
--- a/repos/system_upgrade/common/libraries/overlaygen.py
|
|
+++ b/repos/system_upgrade/common/libraries/overlaygen.py
|
|
@@ -185,7 +185,7 @@ def _get_fspace(path, convert_to_mibs=False, coefficient=1):
|
|
coefficient = min(coefficient, 1)
|
|
fspace_bytes = int(stat.f_frsize * stat.f_bavail * coefficient)
|
|
if convert_to_mibs:
|
|
- return int(fspace_bytes / 1024 / 1024) # noqa: W1619; pylint: disable=old-division
|
|
+ return int(fspace_bytes / 1024 / 1024)
|
|
return fspace_bytes
|
|
|
|
|
|
@@ -325,7 +325,7 @@ def _prepare_required_mounts(scratch_dir, mounts_dir, storage_info, scratch_rese
|
|
|
|
@contextlib.contextmanager
|
|
def _build_overlay_mount(root_mount, mounts):
|
|
- # noqa: W0135; pylint: disable=contextmanager-generator-missing-cleanup
|
|
+ # noqa: W0135; pylint: disable=bad-option-value,contextmanager-generator-missing-cleanup
|
|
# NOTE(pstodulk): the pylint check is not valid in this case - finally is covered
|
|
# implicitly
|
|
if not root_mount:
|
|
@@ -480,8 +480,8 @@ def _create_mount_disk_image(disk_images_directory, path, disk_size):
|
|
# NOTE(pstodulk): In case the formatting params are modified,
|
|
# the minimal required size could be different
|
|
api.current_logger().warning(
|
|
- 'The apparent size for the disk image representing {path}'
|
|
- ' is too small ({disk_size} MiBs) for a formatting. Setting 130 MiBs instead.'
|
|
+ 'The apparent size for the disk image representing {path} '
|
|
+ 'is too small ({disk_size} MiBs) for a formatting. Setting 130 MiBs instead.'
|
|
.format(path=path, disk_size=disk_size)
|
|
)
|
|
disk_size = 130
|
|
@@ -489,12 +489,11 @@ def _create_mount_disk_image(disk_images_directory, path, disk_size):
|
|
cmd = [
|
|
'/bin/dd',
|
|
'if=/dev/zero', 'of={}'.format(diskimage_path),
|
|
- 'bs=1M', 'count=0', 'seek={}'.format(disk_size)
|
|
+ 'bs=1M', 'count=0', 'seek={}'.format(disk_size),
|
|
]
|
|
hint = (
|
|
'Please ensure that there is enough diskspace on the partition hosting'
|
|
- 'the {} directory.'
|
|
- .format(disk_images_directory)
|
|
+ 'the {} directory.'.format(disk_images_directory)
|
|
)
|
|
|
|
api.current_logger().debug('Attempting to create disk image at %s', diskimage_path)
|
|
@@ -540,7 +539,9 @@ def _create_mounts_dir(scratch_dir, mounts_dir):
|
|
utils.makedirs(mounts_dir)
|
|
api.current_logger().debug('Done creating mount directories.')
|
|
except OSError:
|
|
- api.current_logger().error('Failed to create mounting directories %s', mounts_dir, exc_info=True)
|
|
+ api.current_logger().error(
|
|
+ 'Failed to create mounting directories %s', mounts_dir, exc_info=True
|
|
+ )
|
|
|
|
# This is an attempt for giving the user a chance to resolve it on their own
|
|
raise StopActorExecutionError(
|
|
@@ -556,17 +557,25 @@ def _mount_dnf_cache(overlay_target):
|
|
"""
|
|
Convenience context manager to ensure bind mounted /var/cache/dnf and removal of the mount.
|
|
"""
|
|
- # noqa: W0135; pylint: disable=contextmanager-generator-missing-cleanup
|
|
+ # noqa: W0135; pylint: disable=bad-option-value,contextmanager-generator-missing-cleanup
|
|
# NOTE(pstodulk): the pylint check is not valid in this case - finally is covered
|
|
# implicitly
|
|
with mounting.BindMount(
|
|
- source='/var/cache/dnf',
|
|
- target=os.path.join(overlay_target, 'var', 'cache', 'dnf')) as cache_mount:
|
|
+ source='/var/cache/dnf',
|
|
+ target=os.path.join(overlay_target, 'var', 'cache', 'dnf'),
|
|
+ ) as cache_mount:
|
|
yield cache_mount
|
|
|
|
|
|
@contextlib.contextmanager
|
|
-def create_source_overlay(mounts_dir, scratch_dir, xfs_info, storage_info, mount_target=None, scratch_reserve=0):
|
|
+def create_source_overlay(
|
|
+ mounts_dir,
|
|
+ scratch_dir,
|
|
+ xfs_info,
|
|
+ storage_info,
|
|
+ mount_target=None,
|
|
+ scratch_reserve=0,
|
|
+):
|
|
"""
|
|
Context manager that prepares the source system overlay and yields the mount.
|
|
|
|
@@ -610,7 +619,7 @@ def create_source_overlay(mounts_dir, scratch_dir, xfs_info, storage_info, mount
|
|
:type scratch_reserve: Optional[int]
|
|
:rtype: mounting.BindMount or mounting.NullMount
|
|
"""
|
|
- # noqa: W0135; pylint: disable=contextmanager-generator-missing-cleanup
|
|
+ # noqa: W0135; pylint: disable=bad-option-value,contextmanager-generator-missing-cleanup
|
|
# NOTE(pstodulk): the pylint check is not valid in this case - finally is covered
|
|
# implicitly
|
|
api.current_logger().debug('Creating source overlay in {scratch_dir} with mounts in {mounts_dir}'.format(
|
|
diff --git a/repos/system_upgrade/common/libraries/tests/test_distro.py b/repos/system_upgrade/common/libraries/tests/test_distro.py
|
|
index 8e866455..13e782e6 100644
|
|
--- a/repos/system_upgrade/common/libraries/tests/test_distro.py
|
|
+++ b/repos/system_upgrade/common/libraries/tests/test_distro.py
|
|
@@ -168,7 +168,8 @@ def test_get_distro_repoids(
|
|
monkeypatch.setattr(os.path, 'exists', lambda f: f in _CENTOS_REPOFILES)
|
|
|
|
class MockedContext:
|
|
- def full_path(self, path):
|
|
+ @staticmethod
|
|
+ def full_path(path):
|
|
return path
|
|
|
|
repoids = get_distro_repoids(MockedContext(), distro_id, '9', 'x86_64')
|
|
diff --git a/repos/system_upgrade/common/libraries/tests/test_grub.py b/repos/system_upgrade/common/libraries/tests/test_grub.py
|
|
index d6f428bb..08dc6895 100644
|
|
--- a/repos/system_upgrade/common/libraries/tests/test_grub.py
|
|
+++ b/repos/system_upgrade/common/libraries/tests/test_grub.py
|
|
@@ -23,7 +23,7 @@ INVALID_DD = b'Nothing to see here!'
|
|
|
|
CUR_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
-# pylint: disable=E501
|
|
+# pylint: disable=line-too-long
|
|
# flake8: noqa: E501
|
|
EFIBOOTMGR_OUTPUT = r"""
|
|
BootCurrent: 0006
|
|
diff --git a/repos/system_upgrade/common/libraries/tests/test_rhsm.py b/repos/system_upgrade/common/libraries/tests/test_rhsm.py
|
|
index 84a1bd5e..b118da29 100644
|
|
--- a/repos/system_upgrade/common/libraries/tests/test_rhsm.py
|
|
+++ b/repos/system_upgrade/common/libraries/tests/test_rhsm.py
|
|
@@ -73,7 +73,8 @@ class IsolatedActionsMocked:
|
|
# A map from called commands to their mocked output
|
|
self.mocked_command_call_outputs = dict()
|
|
|
|
- def is_isolated(self):
|
|
+ @staticmethod
|
|
+ def is_isolated():
|
|
return True
|
|
|
|
def call(self, cmd, *args, **dummy_kwargs):
|
|
@@ -93,7 +94,8 @@ class IsolatedActionsMocked:
|
|
'exit_code': exit_code
|
|
}
|
|
|
|
- def full_path(self, path):
|
|
+ @staticmethod
|
|
+ def full_path(path):
|
|
return path
|
|
|
|
def remove(self, path):
|
|
diff --git a/repos/system_upgrade/common/libraries/testutils.py b/repos/system_upgrade/common/libraries/testutils.py
|
|
index 328a7ede..e84cc03a 100644
|
|
--- a/repos/system_upgrade/common/libraries/testutils.py
|
|
+++ b/repos/system_upgrade/common/libraries/testutils.py
|
|
@@ -120,7 +120,7 @@ class CurrentActorMocked: # pylint:disable=R0904
|
|
return os.path.join(self._common_tools_folder, name)
|
|
|
|
def consume(self, model):
|
|
- return iter(filter( # pylint:disable=W0110,W1639
|
|
+ return iter(filter(
|
|
lambda msg: isinstance(msg, model), self._msgs
|
|
))
|
|
|
|
diff --git a/repos/system_upgrade/el8toel9/actors/checkvdo/tests/unit_test_checkvdo.py b/repos/system_upgrade/el8toel9/actors/checkvdo/tests/unit_test_checkvdo.py
|
|
index 865e036f..d7cfb4fb 100644
|
|
--- a/repos/system_upgrade/el8toel9/actors/checkvdo/tests/unit_test_checkvdo.py
|
|
+++ b/repos/system_upgrade/el8toel9/actors/checkvdo/tests/unit_test_checkvdo.py
|
|
@@ -15,13 +15,15 @@ from leapp.utils.report import is_inhibitor
|
|
|
|
# Mock actor base for CheckVdo tests.
|
|
class MockedActorCheckVdo(CurrentActorMocked):
|
|
- def get_vdo_answer(self):
|
|
+ @staticmethod
|
|
+ def get_vdo_answer():
|
|
return False
|
|
|
|
|
|
# Mock actor for all_vdo_converted dialog response.
|
|
class MockedActorAllVdoConvertedTrue(MockedActorCheckVdo):
|
|
- def get_vdo_answer(self):
|
|
+ @staticmethod
|
|
+ def get_vdo_answer():
|
|
return True
|
|
|
|
|
|
diff --git a/repos/system_upgrade/el8toel9/actors/nisscanner/libraries/nisscan.py b/repos/system_upgrade/el8toel9/actors/nisscanner/libraries/nisscan.py
|
|
index 9910f748..ae51c69d 100644
|
|
--- a/repos/system_upgrade/el8toel9/actors/nisscanner/libraries/nisscan.py
|
|
+++ b/repos/system_upgrade/el8toel9/actors/nisscanner/libraries/nisscan.py
|
|
@@ -14,7 +14,8 @@ class NISScanLibrary:
|
|
Helper library for NISScan actor.
|
|
"""
|
|
|
|
- def client_has_non_default_configuration(self):
|
|
+ @staticmethod
|
|
+ def client_has_non_default_configuration():
|
|
"""
|
|
Check for any significant ypbind configuration lines in .conf file.
|
|
"""
|
|
@@ -31,7 +32,8 @@ class NISScanLibrary:
|
|
return True
|
|
return False
|
|
|
|
- def server_has_non_default_configuration(self):
|
|
+ @staticmethod
|
|
+ def server_has_non_default_configuration():
|
|
"""
|
|
Check for any additional (not default) files in ypserv DIR.
|
|
"""
|
|
diff --git a/repos/system_upgrade/el8toel9/actors/opensslconfigcheck/libraries/opensslconfigcheck.py b/repos/system_upgrade/el8toel9/actors/opensslconfigcheck/libraries/opensslconfigcheck.py
|
|
index f36a62e1..07c1b22f 100644
|
|
--- a/repos/system_upgrade/el8toel9/actors/opensslconfigcheck/libraries/opensslconfigcheck.py
|
|
+++ b/repos/system_upgrade/el8toel9/actors/opensslconfigcheck/libraries/opensslconfigcheck.py
|
|
@@ -115,7 +115,8 @@ def _openssl_reachable_key(config, key, value=None):
|
|
return False
|
|
|
|
|
|
-# pylint: disable=too-many-return-statements -- could not simplify more
|
|
+# pylint: disable=too-many-return-statements
|
|
+# could not simplify more
|
|
def _openssl_reachable_path(config, path, value=None):
|
|
"""
|
|
Check if the given path is reachable in OpenSSL configuration
|
|
--
|
|
2.51.1
|
|
|