aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2020-07-29 11:27:16 -0700
committerZac Medico <zmedico@gentoo.org>2020-07-29 21:05:06 -0700
commit709826c0896120e8b3d9995d71678c0b9b290e4c (patch)
treea1864886deaa849c8391dbc4427a2b6ede74a589 /lib/_emerge/depgraph.py
parentSilence 'mixed-indentation' warning. (diff)
downloadportage-709826c0896120e8b3d9995d71678c0b9b290e4c.tar.gz
portage-709826c0896120e8b3d9995d71678c0b9b290e4c.tar.bz2
portage-709826c0896120e8b3d9995d71678c0b9b290e4c.zip
Fix R1705.
The codebase appears to have this pattern like: if foo == bar: return a elif foo == baz: return b else: return c This can often be rewritten as: if foo == bar: return a if foo == baz: return b return c Closes: https://github.com/gentoo/portage/pull/592 Signed-off-by: Alec Warner <antarus@gentoo.org> Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib/_emerge/depgraph.py')
-rw-r--r--lib/_emerge/depgraph.py131
1 files changed, 64 insertions, 67 deletions
diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py
index 3ff90190d..04b824ab9 100644
--- a/lib/_emerge/depgraph.py
+++ b/lib/_emerge/depgraph.py
@@ -262,7 +262,7 @@ class _rebuild_config:
if self._needs_rebuild(dep_pkg):
self.rebuild_list.add(root_slot)
return True
- elif ("--usepkg" in self._frozen_config.myopts and
+ if ("--usepkg" in self._frozen_config.myopts and
(dep_root_slot in self.reinstall_list or
dep_root_slot in self.rebuild_list or
not dep_pkg.installed)):
@@ -296,7 +296,7 @@ class _rebuild_config:
# built without dep_pkg. Force rebuild.
self.rebuild_list.add(root_slot)
return True
- elif (parent.installed and
+ if (parent.installed and
root_slot not in self.reinstall_list):
try:
bin_build_time, = bindb.aux_get(parent.cpv,
@@ -2566,14 +2566,14 @@ class depgraph:
Atom("=%s" % inst_pkg.cpv)):
if not pkg.built:
return pkg.slot_atom
- elif not pkg.installed:
+ if not pkg.installed:
# avoid using SLOT from a built instance
built_pkgs.append(pkg)
for pkg in self._iter_similar_available(inst_pkg, inst_pkg.slot_atom):
if not pkg.built:
return pkg.slot_atom
- elif not pkg.installed:
+ if not pkg.installed:
# avoid using SLOT from a built instance
built_pkgs.append(pkg)
@@ -2899,58 +2899,58 @@ class depgraph:
self._slot_operator_unsatisfied_probe(dep)):
self._slot_operator_unsatisfied_backtrack(dep)
return 1
- else:
- # This is for backward-compatibility with previous
- # behavior, so that installed packages with unsatisfied
- # dependencies trigger an error message but do not
- # cause the dependency calculation to fail. Only do
- # this if the parent is already in the runtime package
- # mask, since otherwise we need to backtrack.
- if (dep.parent.installed and
- dep.parent in self._dynamic_config._runtime_pkg_mask and
- not any(self._iter_match_pkgs_any(
- dep.parent.root_config, dep.atom))):
- self._dynamic_config._initially_unsatisfied_deps.append(dep)
- return 1
-
- # Do not backtrack if only USE have to be changed in
- # order to satisfy the dependency. Note that when
- # want_restart_for_use_change sets the need_restart
- # flag, it causes _select_pkg_highest_available to
- # return None, and eventually we come through here
- # and skip the "missing dependency" backtracking path.
- dep_pkg, existing_node = \
- self._select_package(dep.root,
- dep.atom.without_use if dep.atom.package
- else dep.atom, onlydeps=dep.onlydeps)
- if dep_pkg is None:
-
- # In order to suppress the sort of aggressive
- # backtracking that can trigger undesirable downgrades
- # as in bug 693836, do not backtrack if there's an
- # available package which was involved in a slot
- # conflict and satisfied all involved parent atoms.
- for dep_pkg, reasons in self._dynamic_config._runtime_pkg_mask.items():
- if (dep.atom.match(dep_pkg) and
- len(reasons) == 1 and
- not reasons.get("slot conflict", True)):
- self._dynamic_config._skip_restart = True
- return 0
- self._dynamic_config._backtrack_infos["missing dependency"] = dep
- self._dynamic_config._need_restart = True
- if debug:
- msg = []
- msg.append("")
- msg.append("")
- msg.append("backtracking due to unsatisfied dep:")
- msg.append(" parent: %s" % dep.parent)
- msg.append(" priority: %s" % dep.priority)
- msg.append(" root: %s" % dep.root)
- msg.append(" atom: %s" % dep.atom)
- msg.append("")
- writemsg_level("".join("%s\n" % l for l in msg),
- noiselevel=-1, level=logging.DEBUG)
+ # This is for backward-compatibility with previous
+ # behavior, so that installed packages with unsatisfied
+ # dependencies trigger an error message but do not
+ # cause the dependency calculation to fail. Only do
+ # this if the parent is already in the runtime package
+ # mask, since otherwise we need to backtrack.
+ if (dep.parent.installed and
+ dep.parent in self._dynamic_config._runtime_pkg_mask and
+ not any(self._iter_match_pkgs_any(
+ dep.parent.root_config, dep.atom))):
+ self._dynamic_config._initially_unsatisfied_deps.append(dep)
+ return 1
+
+ # Do not backtrack if only USE have to be changed in
+ # order to satisfy the dependency. Note that when
+ # want_restart_for_use_change sets the need_restart
+ # flag, it causes _select_pkg_highest_available to
+ # return None, and eventually we come through here
+ # and skip the "missing dependency" backtracking path.
+ dep_pkg, existing_node = \
+ self._select_package(dep.root,
+ dep.atom.without_use if dep.atom.package
+ else dep.atom, onlydeps=dep.onlydeps)
+ if dep_pkg is None:
+
+ # In order to suppress the sort of aggressive
+ # backtracking that can trigger undesirable downgrades
+ # as in bug 693836, do not backtrack if there's an
+ # available package which was involved in a slot
+ # conflict and satisfied all involved parent atoms.
+ for dep_pkg, reasons in self._dynamic_config._runtime_pkg_mask.items():
+ if (dep.atom.match(dep_pkg) and
+ len(reasons) == 1 and
+ not reasons.get("slot conflict", True)):
+ self._dynamic_config._skip_restart = True
+ return 0
+
+ self._dynamic_config._backtrack_infos["missing dependency"] = dep
+ self._dynamic_config._need_restart = True
+ if debug:
+ msg = []
+ msg.append("")
+ msg.append("")
+ msg.append("backtracking due to unsatisfied dep:")
+ msg.append(" parent: %s" % dep.parent)
+ msg.append(" priority: %s" % dep.priority)
+ msg.append(" root: %s" % dep.root)
+ msg.append(" atom: %s" % dep.atom)
+ msg.append("")
+ writemsg_level("".join("%s\n" % l for l in msg),
+ noiselevel=-1, level=logging.DEBUG)
return 0
@@ -3190,7 +3190,7 @@ class depgraph:
dep_stack = self._dynamic_config._dep_stack
if "recurse" not in self._dynamic_config.myparams:
return 1
- elif pkg.installed and not recurse:
+ if pkg.installed and not recurse:
dep_stack = self._dynamic_config._ignored_deps
self._spinner_update()
@@ -5656,9 +5656,8 @@ class depgraph:
if atom.package:
return self._iter_match_pkgs_atom(root_config, pkg_type,
atom, onlydeps=onlydeps)
- else:
- return self._iter_match_pkgs_soname(root_config, pkg_type,
- atom, onlydeps=onlydeps)
+ return self._iter_match_pkgs_soname(root_config, pkg_type,
+ atom, onlydeps=onlydeps)
def _iter_match_pkgs_soname(self, root_config, pkg_type, atom,
onlydeps=False):
@@ -5873,12 +5872,11 @@ class depgraph:
deep = self._dynamic_config.myparams.get("deep", 0)
if depth is self._UNREACHABLE_DEPTH:
return True
- elif deep is True:
+ if deep is True:
return False
- else:
- # All non-integer cases are handled above,
- # so both values must be int type.
- return depth > deep
+ # All non-integer cases are handled above,
+ # so both values must be int type.
+ return depth > deep
def _depth_increment(self, depth, n=1):
"""
@@ -6161,8 +6159,7 @@ class depgraph:
if target_use is None:
if needed_use_config_change is None:
return pkg.use.enabled
- else:
- return needed_use_config_change[0]
+ return needed_use_config_change[0]
if needed_use_config_change is not None:
old_use = needed_use_config_change[0]
@@ -9747,7 +9744,7 @@ class _dep_check_composite_db(dbapi):
if not avoid_update:
if not use_ebuild_visibility and usepkgonly:
return False
- elif not self._depgraph._equiv_ebuild_visible(pkg):
+ if not self._depgraph._equiv_ebuild_visible(pkg):
return False
if pkg.cp.startswith("virtual/"):