]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ukify: make code pylint clean
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 1 Jun 2023 08:39:54 +0000 (10:39 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 5 Jun 2023 14:07:52 +0000 (16:07 +0200)
The linter is imperfect, but it is useful as a very quick
check for typos and other silly mistakes. Add a few annotations
and do one small change to make it think the code is perfect.

src/ukify/ukify.py

index 19896afac3734b56fd63d19c9978c517e7e01958..88189d272d9e11cbeabb537b7ac08980c632319e 100755 (executable)
@@ -19,7 +19,9 @@
 # pylint: disable=missing-docstring,invalid-name,import-outside-toplevel
 # pylint: disable=consider-using-with,unspecified-encoding,line-too-long
 # pylint: disable=too-many-locals,too-many-statements,too-many-return-statements
-# pylint: disable=too-many-branches,fixme
+# pylint: disable=too-many-branches,too-many-lines,too-many-instance-attributes
+# pylint: disable=too-many-arguments,unnecessary-lambda-assignment,fixme
+# pylint: disable=unused-argument
 
 import argparse
 import configparser
@@ -438,7 +440,7 @@ def call_systemd_measure(uki, linux, opts):
 def join_initrds(initrds):
     if len(initrds) == 0:
         return None
-    elif len(initrds) == 1:
+    if len(initrds) == 1:
         return initrds[0]
 
     seq = []
@@ -478,6 +480,9 @@ def pe_add_sections(uki: UKI, output: str):
             pe.FILE_HEADER.IMAGE_FILE_LOCAL_SYMS_STRIPPED = True
 
     # Old stubs might have been stripped, leading to unaligned raw data values, so let's fix them up here.
+    # pylint thinks that Structure doesn't have various members that it has…
+    # pylint: disable=no-member
+
     for i, section in enumerate(pe.sections):
         oldp = section.PointerToRawData
         oldsz = section.SizeOfRawData
@@ -745,6 +750,7 @@ class ConfigItem:
     ) -> None:
         "Set namespace.<dest>[idx] to value, with idx derived from group"
 
+        # pylint: disable=protected-access
         if group not in namespace._groups:
             namespace._groups += [group]
         idx = namespace._groups.index(group)
@@ -1068,7 +1074,7 @@ def apply_config(namespace, filename=None):
     # Fill in ._groups based on --pcr-public-key=, --pcr-private-key=, and --phases=.
     assert '_groups' not in namespace
     n_pcr_priv = len(namespace.pcr_private_keys or ())
-    namespace._groups = list(range(n_pcr_priv))
+    namespace._groups = list(range(n_pcr_priv))  # pylint: disable=protected-access
 
     cp = configparser.ConfigParser(
         comment_prefixes='#',