Skip to content

Commit

Permalink
package_manager: fix linter issues
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
praiskup authored and xsuchy committed Sep 30, 2024
1 parent 0c41fd9 commit 516144a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mock/py/mockbuild/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down

0 comments on commit 516144a

Please sign in to comment.