diff mbox series

[auh,4/5] Fix linting errors reported by ruff

Message ID 20260104004708.2494403-8-t.f.g.geelen@gmail.com
State New
Headers show
Series [auh,1/5] README: fix version numbering. | expand

Commit Message

Tom Geelen Jan. 4, 2026, 12:47 a.m. UTC
Ruff (or any other linter) should not report any errors when run on the
codebase. This patch fixes various such errors.

---
 modules/buildhistory.py  |  6 +++---
 modules/steps.py         |  8 ++++----
 modules/testimage.py     |  3 +--
 modules/utils/bitbake.py |  2 +-
 modules/utils/devtool.py |  3 ++-
 modules/utils/git.py     |  3 ++-
 upgrade-helper.py        | 17 +++++++----------
 7 files changed, 20 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/modules/buildhistory.py b/modules/buildhistory.py
index 407a1e5..c045a73 100644
--- a/modules/buildhistory.py
+++ b/modules/buildhistory.py
@@ -20,11 +20,11 @@ 
 #
 
 import os
+import re
 from logging import warning as W
 
-from errors import *
-from utils.git import Git
-from utils.bitbake import *
+from errors import Error
+from utils.bitbake import bb
 
 class BuildHistory(object):
     def __init__(self, bb, group):
diff --git a/modules/steps.py b/modules/steps.py
index 93cb3a6..f7dd5c5 100644
--- a/modules/steps.py
+++ b/modules/steps.py
@@ -27,7 +27,7 @@  from logging import debug as D
 from logging import info as I
 from logging import warning as W
 
-from errors import *
+from errors import Error, DevtoolError, CompilationError
 from buildhistory import BuildHistory
 
 def load_env(devtool, bb, git, opts, group):
@@ -59,9 +59,9 @@  def _extract_license_diff(devtool_output):
                 for line in lines:
                      if line.startswith(b'# FIXME: the LIC_FILES_CHKSUM'):
                          extracting = True
-                     elif extracting == True and not line.startswith(b'#') and len(line) > 1:
+                     elif extracting and not line.startswith(b'#') and len(line) > 1:
                          extracting = False
-                     if extracting == True:
+                     if extracting:
                          licenseinfo.append(line[2:])
                      else:
                          f.write(line)
@@ -71,7 +71,7 @@  def _extract_license_diff(devtool_output):
 def _make_commit_msg(group):
     def _get_version(p):
         if p['NPV'].endswith("new-commits-available"):
-            return "to latest revision".format(p['PN'])
+            return "to latest revision"
         else:
             return "{} -> {}".format(p['PV'], p['NPV'])
 
diff --git a/modules/testimage.py b/modules/testimage.py
index 85ee4f3..b96782d 100644
--- a/modules/testimage.py
+++ b/modules/testimage.py
@@ -25,8 +25,7 @@  import os
 
 from logging import info as I
 
-from errors import *
-from utils.bitbake import *
+from errors import Error
 
 def _pn_in_pkgs_ctx(pn, pkgs_ctx):
     for c in pkgs_ctx:
diff --git a/modules/utils/bitbake.py b/modules/utils/bitbake.py
index ad011db..5514c98 100644
--- a/modules/utils/bitbake.py
+++ b/modules/utils/bitbake.py
@@ -28,7 +28,7 @@  from logging import debug as D
 import sys
 import re
 
-from errors import *
+from errors import Error, EmptyEnvError
 
 for path in os.environ["PATH"].split(':'):
     if os.path.exists(path) and "bitbake" in os.listdir(path):
diff --git a/modules/utils/devtool.py b/modules/utils/devtool.py
index d4b7ba7..4d4307f 100644
--- a/modules/utils/devtool.py
+++ b/modules/utils/devtool.py
@@ -1,7 +1,8 @@ 
 # SPDX-License-Identifier: GPL-2.0-or-later
 from logging import debug as D
 
-from utils.bitbake import *
+from utils.bitbake import bb
+from errors import DevtoolError
 
 class Devtool(object):
     def __init__(self):
diff --git a/modules/utils/git.py b/modules/utils/git.py
index abc1acc..3be75bf 100644
--- a/modules/utils/git.py
+++ b/modules/utils/git.py
@@ -26,7 +26,8 @@ 
 import os
 from logging import debug as D
 
-from utils.bitbake import *
+from utils.bitbake import bb
+from errors import Error
 
 class Git(object):
     def __init__(self, dir):
diff --git a/upgrade-helper.py b/upgrade-helper.py
index 93a0bf3..165fd42 100755
--- a/upgrade-helper.py
+++ b/upgrade-helper.py
@@ -49,11 +49,11 @@  import shutil
 sys.path.insert(1, os.path.join(os.path.abspath(
     os.path.dirname(__file__)), 'modules'))
 
-from errors import *
+from errors import Error, EmptyEnvError, UpgradeNotNeededError, UnsupportedProtocolError
 
 from utils.git import Git
 from utils.devtool import Devtool
-from utils.bitbake import *
+from utils.bitbake import Bitbake, get_build_dir
 from utils.emailhandler import Email
 
 from statistics import Statistics
@@ -66,7 +66,6 @@  if not os.getenv('BUILDDIR', False):
     E(" $ . oe-init-build-env build-auh\n")
     exit(1)
 
-import shutil
 # Use the location of devtool to find scriptpath and hence bb/oe libs
 scripts_path = os.path.abspath(os.path.dirname(shutil.which("devtool")))
 sys.path = sys.path + [scripts_path + '/lib']
@@ -235,7 +234,7 @@  class Updater(object):
 
         if settings.get("buildhistory", "no") == "yes":
             if 'buildhistory' in self.base_env['INHERIT']:
-                if not 'BUILDHISTORY_COMMIT' in self.base_env:
+                if 'BUILDHISTORY_COMMIT' not in self.base_env:
                     E(" Buildhistory was INHERIT in conf/local.conf"\
                       " but need BUILDHISTORY_COMMIT=1 please set.")
                     exit(1)
@@ -263,7 +262,7 @@  class Updater(object):
 
         if settings.get("testimage", "no") == "yes":
             if 'testimage' in self.base_env['IMAGE_CLASSES']:
-                if not "ptest" in self.base_env["DISTRO_FEATURES"]:
+                if "ptest" not in self.base_env["DISTRO_FEATURES"]:
                     E(" testimage requires ptest in DISTRO_FEATURES please add to"\
                       " conf/local.conf.")
                     exit(1)
@@ -355,7 +354,7 @@  class Updater(object):
         if license_diffs:
             msg_body += license_change_info % license_diffs
 
-        if 'patch_file' in g and g['patch_file'] != None:
+        if 'patch_file' in g and g['patch_file'] is not None:
             msg_body += next_steps_info % (os.path.basename(g['patch_file']))
 
         msg_body += mail_footer
@@ -514,7 +513,6 @@  class Updater(object):
                         import traceback
                         msg = "Failed(unknown error)\n" + traceback.format_exc()
                         e = Error(message=msg)
-                        error = e
 
                     E(" %s: %s" % (pkggroup_name, e.message))
 
@@ -617,7 +615,6 @@  class UniverseUpdater(Updater):
         recipe_regex = re.compile('^(?P<name>.*):$')
         layer_regex = re.compile('^  (?P<name>.*) +')
 
-        layers = False
         name = ''
 
         output = subprocess.check_output('bitbake-layers show-recipes',
@@ -628,7 +625,7 @@  class UniverseUpdater(Updater):
                 name = s.group('name')
                 continue
 
-            if not 'skipped' in line:
+            if 'skipped' not in line:
                 s = layer_regex.search(line)
                 if s:
                     if s.group('name').strip() == layer:
@@ -667,7 +664,7 @@  class UniverseUpdater(Updater):
                     found = True
                     break
 
-            if found == False:
+            if not found:
                 D(" Skipping upgrade of %s: maintainer \"%s\" not in whitelist" %
                         (pn, maintainer))
                 return False