[elbe-devel] [PATCH 12/13] pylint - fix Unnecessary "else" after "return"

Manuel Traut manut at linutronix.de
Thu Aug 30 17:05:23 CEST 2018


Unnecessary "else" after "return"

aptpkgutils.py:51, PyLint, Priority: Low
elbexml.py:84, PyLint, Priority: Low
elbexml.py:392, PyLint, Priority: Low
elbexml.py:413, PyLint, Priority: Low
fstab.py:34, PyLint, Priority: Low
licencexml.py:32, PyLint, Priority: Low
pkgutils.py:177, PyLint, Priority: Low
repomanager.py:42, PyLint, Priority: Low
repomanager.py:100, PyLint, Priority: Low
templates.py:24, PyLint, Priority: Low
treeutils.py:47, PyLint, Priority: Low
treeutils.py:60, PyLint, Priority: Low
treeutils.py:90, PyLint, Priority: Low
treeutils.py:128, PyLint, Priority: Low

Signed-off-by: Manuel Traut <manut at linutronix.de>
---
 elbepack/aptpkgutils.py |  4 ++--
 elbepack/elbexml.py     |  9 +++------
 elbepack/fstab.py       |  4 ++--
 elbepack/licencexml.py  |  4 ++--
 elbepack/pkgutils.py    |  5 +----
 elbepack/repomanager.py | 19 +++++++------------
 elbepack/templates.py   |  4 ++--
 elbepack/treeutils.py   | 16 ++++++++--------
 8 files changed, 27 insertions(+), 38 deletions(-)

diff --git a/elbepack/aptpkgutils.py b/elbepack/aptpkgutils.py
index 1078063d..9c8b37ce 100644
--- a/elbepack/aptpkgutils.py
+++ b/elbepack/aptpkgutils.py
@@ -58,8 +58,8 @@ def pkgstate(pkg):
         return UPGRADABLE
     elif pkg.is_installed:
         return INSTALLED
-    else:
-        return NOTINSTALLED
+
+    return NOTINSTALLED
 
 
 def pkgorigin(pkg):
diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index a5ba32d7..72b24e75 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -83,8 +83,7 @@ class ElbeXML(object):
     def text(self, txt, key=None):
         if key:
             return self.xml.text(txt, default=self.defs, key=key)
-        else:
-            return self.xml.text(txt)
+        return self.xml.text(txt)
 
     def has(self, path):
         return self.xml.has(path)
@@ -391,8 +390,7 @@ class ElbeXML(object):
     def get_initvm_codename(self):
         if self.has("initvm/suite"):
             return self.text("initvm/suite")
-        else:
-            return None
+        return None
 
     def set_cdrom_mirror(self, abspath):
         mirror = self.node("project/mirror")
@@ -412,5 +410,4 @@ class ElbeXML(object):
     def get_elbe_version(self):
         if self.has('elbe_version'):
             return self.text('elbe_version')
-        else:
-            return "no version"
+        return "no version"
diff --git a/elbepack/fstab.py b/elbepack/fstab.py
index fe6e4517..214db2a1 100644
--- a/elbepack/fstab.py
+++ b/elbepack/fstab.py
@@ -34,8 +34,8 @@ def get_devicelabel(xml, node):
     if node.text("fs/type") == "ubifs":
         return "ubi %s:%s" % (get_mtdnum(xml, node.text("label")),
                               node.text("label"))
-    else:
-        return "LABEL=" + node.text("label")
+
+    return "LABEL=" + node.text("label")
 
 
 class mountpoint_dict (dict):
diff --git a/elbepack/licencexml.py b/elbepack/licencexml.py
index 9c277ff5..6324fe4f 100644
--- a/elbepack/licencexml.py
+++ b/elbepack/licencexml.py
@@ -31,8 +31,8 @@ def do_heuristics(fp):
 
     if num_licenses > 0:
         return c
-    else:
-        return None
+
+    return None
 
 
 def get_heuristics_license_list(c):
diff --git a/elbepack/pkgutils.py b/elbepack/pkgutils.py
index 84eaac02..0a68a819 100644
--- a/elbepack/pkgutils.py
+++ b/elbepack/pkgutils.py
@@ -187,10 +187,7 @@ def get_uri(prj, defs, arch, target_pkg, incl_deps=False):
         ret = v.get_uri(target_pkg, incl_deps)
         return ret
 
-    else:
-        return get_uri_nonvirtapt(apt_sources, target_pkg, arch)
-
-    return [(target_pkg, "nonexistent://" + target_pkg, "")]
+    return get_uri_nonvirtapt(apt_sources, target_pkg, arch)
 
 
 def get_dsc_size(fname):
diff --git a/elbepack/repomanager.py b/elbepack/repomanager.py
index a89a45c3..9b6085a6 100644
--- a/elbepack/repomanager.py
+++ b/elbepack/repomanager.py
@@ -41,17 +41,12 @@ class RepoAttributes(object):
 
         if other.codename != self.codename:
             return [self, other]
-        else:
-            assert self.mirror == other.mirror
-            ret_arch = self.arch.union(other.arch)
-            ret_comp = self.components.union(other.components)
 
-            return [
-                RepoAttributes(
-                    self.codename,
-                    ret_arch,
-                    ret_comp,
-                    self.mirror)]
+        assert self.mirror == other.mirror
+        ret_arch = self.arch.union(other.arch)
+        ret_comp = self.components.union(other.components)
+
+        return [RepoAttributes(self.codename, ret_arch, ret_comp, self.mirror)]
 
 
 class RepoBase(object):
@@ -100,8 +95,8 @@ class RepoBase(object):
         if self.maxsize:
             volname = os.path.join(self.vol_path, "vol%02d" % volume)
             return Filesystem(volname)
-        else:
-            return Filesystem(self.vol_path)
+
+        return Filesystem(self.vol_path)
 
     def new_repo_volume(self):
         self.volume_count += 1
diff --git a/elbepack/templates.py b/elbepack/templates.py
index 8552595c..6d902278 100644
--- a/elbepack/templates.py
+++ b/elbepack/templates.py
@@ -26,8 +26,8 @@ def template(fname, d, linebreak=False):
                 filename=fname,
                 preprocessor=fix_linebreak_escapes).render(
                 **d)
-        else:
-            return Template(filename=fname).render(**d)
+
+        return Template(filename=fname).render(**d)
     except BaseException:
         print(exceptions.text_error_template().render())
         raise
diff --git a/elbepack/treeutils.py b/elbepack/treeutils.py
index 383f80e2..8ba635d8 100644
--- a/elbepack/treeutils.py
+++ b/elbepack/treeutils.py
@@ -46,10 +46,10 @@ class ebase(object):
             default = args["default"]
             if isinstance(default, str):
                 return default
-            else:
-                return default[args["key"]]
-        else:
-            return el.text
+
+            return default[args["key"]]
+
+        return el.text
 
     @property
     def tag(self):
@@ -89,8 +89,8 @@ class elem(ebase):
         retval = self.et.find("./" + tag)
         if retval is not None:
             return elem(retval)
-        else:
-            return elem(SubElement(self.et, tag))
+
+        return elem(SubElement(self.et, tag))
 
     def append(self, tag):
         retval = elem(SubElement(self.et, tag))
@@ -127,8 +127,8 @@ class etree(ebase):
         retval = self.et.find("./" + tag)
         if retval is not None:
             return elem(retval)
-        else:
-            return elem(SubElement(self.et.getroot(), tag))
+
+        return elem(SubElement(self.et.getroot(), tag))
 
     def set_child_position(self, child, pos):
         root = self.et.getroot()
-- 
2.18.0




More information about the elbe-devel mailing list