[elbe-devel] [PATCH 49/75] hdimg: Fix Pylint

Olivier Dion dion at linutronix.de
Mon May 25 17:42:42 CEST 2020


266:42: W1401: Anomalous backslash in string: (anomalous-backslash-in-string)
266:50: W1401: Anomalous backslash in string: (anomalous-backslash-in-string)
148:0:  R0205: (useless-object-inheritance)
159:4:  R0201: (no-self-use)
215:15: W0703: (broad-except)
276:15: W0703: (broad-except)
267:30: W0631: (undefined-loop-variable)
269:26: W0631: (undefined-loop-variable)
293:0:  R0205: (useless-object-inheritance)
324:26: I1101: (c-extension-no-member)
332:22: I1101: (c-extension-no-member)
335:22: I1101: (c-extension-no-member)

Requires fix for undefined-loop-variable!

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 .pylintrc         |  2 +-
 elbepack/hdimg.py | 24 +++++++++++++++++-------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index b516d511..59a806a6 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -27,7 +27,7 @@ persistent=yes
 # usually to register additional checkers.
 load-plugins=
 
-extension-pkg-whitelist=lxml
+extension-pkg-whitelist=lxml,_ped
 
 
 [MESSAGES CONTROL]
diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index 5478cbda..40077d9c 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -145,6 +145,8 @@ def build_image_mtd(mtd, target):
     return img_files
 
 
+# TODO:py3 Remove object inheritance
+# pylint: disable=useless-object-inheritance
 class grubinstaller_base(object):
     def __init__(self, fw_type=None):
         self.fs = mountpoint_dict()
@@ -156,7 +158,8 @@ class grubinstaller_base(object):
     def install(self, target):
         pass
 
-    def losetup(self, f):
+    @staticmethod
+    def losetup(f):
         loopdev = get_command_out('losetup --find --show "%s"' % f)
         return loopdev.rstrip('\n')
 
@@ -212,6 +215,7 @@ class grubinstaller202(grubinstaller_base):
                 do("chroot %s grub-install --no-floppy %s" %
                    (imagemnt, poopdev))
 
+        # pylint: disable=broad-except
         except Exception as E:
             logging.exception(E)
 
@@ -261,18 +265,23 @@ class grubinstaller97(grubinstaller_base):
 
             chroot(imagemnt, "update-initramfs -u -k all")
 
-            # Replace groot and kopt because
-            # else they will be given bad values
-            do('chroot %s sed -in "s/^# groot=.*$/# groot=\(hd0,%d\)/" %s' %
+            # Replace groot and kopt because else they will be given
+            # bad values
+            #
+            # FIXME - Pylint says: Using possibly undefined loop variable
+            # 'entry' (undefined-loop-variable).  entry is defined in
+            # the previous for-loop.
+            # # pylint: disable=undefined-loop-variable
+            do(r'chroot %s sed -in "s/^# groot=.*$/# groot=\(hd0,%d\)/" %s' %
                (imagemnt, int(entry.partnum) - 1, "/boot/grub/menu.lst"))
-            do('chroot %s sed -in "s/^# kopt=.*$/# kopt=root=LABEL=%s/" %s' %
+            do(r'chroot %s sed -in "s/^# kopt=.*$/# kopt=root=LABEL=%s/" %s' %
                (imagemnt, entry.label, "/boot/grub/menu.lst"))
 
             chroot(imagemnt, "update-grub")
 
             do("chroot %s grub-install --no-floppy %s" %
                (imagemnt, poopdev))
-
+        # pylint: disable=broad-except
         except Exception as E:
             logging.exception(E)
 
@@ -289,7 +298,8 @@ class grubinstaller97(grubinstaller_base):
             do("kpartx -d %s" % poopdev, allow_fail=True)
             do("losetup -d %s" % poopdev, allow_fail=True)
 
-
+# TODO:py3 Remove object inheritance
+# pylint: disable=useless-object-inheritance
 class simple_fstype(object):
     def __init__(self, typ):
         self.type = typ
-- 
2.26.2




More information about the elbe-devel mailing list