From 99164b6ee9cc6608f60b63394537a6177e954a0e Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Sat, 28 Sep 2024 18:52:38 +0200 Subject: [PATCH] package_manager: fix linter issues The rename of methods makes linter thing these are new issues: - Ignore the f"" warning, as f-string is not optimal for this use-case. - Use RuntimeError instead of the generic Exception. It is still too generic and mock prints stack trace if it happens, but package_manager.py probably deserves it's own exception (#1477). --- mock/py/mockbuild/package_manager.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mock/py/mockbuild/package_manager.py b/mock/py/mockbuild/package_manager.py index b7c4082ee..fa3001dd6 100644 --- a/mock/py/mockbuild/package_manager.py +++ b/mock/py/mockbuild/package_manager.py @@ -34,7 +34,7 @@ def _package_manager_from_string(name): return Dnf if name == 'microdnf': return MicroDnf - raise Exception('Unrecognized package manager "{}"'.format(name)) + raise RuntimeError(f'Unrecognized package manager "{name}"') def _package_manager_exists(pm_class, config_opts, chroot=None): @@ -84,6 +84,7 @@ def _package_manager_class_fallback(config_opts, buildroot, fallback): return pm_class if not bootstrap: + # pylint: disable=consider-using-f-string print("""WARNING! WARNING! WARNING! You are building package for distribution which uses {0}. However your system does not support {0}. You can continue with {1}, which will likely succeed, @@ -97,7 +98,7 @@ def _package_manager_class_fallback(config_opts, buildroot, fallback): return pm_class - raise Exception(f"No package from {fallbacks[desired]} found, desired {desired}") + raise RuntimeError(f"No package from {fallbacks[desired]} found, desired {desired}") def package_manager(buildroot, bootstrap_buildroot, fallback):