Re: [PATCH v4 23/83] buildman: Fix most pylint warnings in control

2023-07-24 Thread Simon Glass
Tidy up the easier-to-fix pylint warnings in module 'control'.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/buildman/control.py   | 119 +---
 tools/buildman/func_test.py |   2 +-
 2 files changed, 71 insertions(+), 50 deletions(-)

Applied to u-boot-dm, thanks!


[PATCH v4 23/83] buildman: Fix most pylint warnings in control

2023-07-19 Thread Simon Glass
Tidy up the easier-to-fix pylint warnings in module 'control'.

Signed-off-by: Simon Glass 
---

(no changes since v1)

 tools/buildman/control.py   | 119 +---
 tools/buildman/func_test.py |   2 +-
 2 files changed, 71 insertions(+), 50 deletions(-)

diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index fac6c45fcdd6..c4be1ad2f4ec 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -15,7 +15,6 @@ except ImportError:
 import importlib_resources
 import os
 import shutil
-import subprocess
 import sys
 
 from buildman import boards
@@ -30,6 +29,8 @@ from u_boot_pylib import terminal
 from u_boot_pylib import tools
 from u_boot_pylib.terminal import tprint
 
+TEST_BUILDER = None
+
 def get_plural(count):
 """Returns a plural 's' if count is not 1"""
 return 's' if count != 1 else ''
@@ -43,17 +44,17 @@ def get_action_summary(is_summary, commits, selected, 
options):
 if commits:
 count = len(commits)
 count = (count + options.step - 1) // options.step
-commit_str = '%d commit%s' % (count, get_plural(count))
+commit_str = f'{count} commit{get_plural(count)}'
 else:
 commit_str = 'current source'
-str = '%s %s for %d boards' % (
-'Summary of' if is_summary else 'Building', commit_str,
-len(selected))
-str += ' (%d thread%s, %d job%s per thread)' % (options.threads,
-get_plural(options.threads), options.jobs, 
get_plural(options.jobs))
-return str
-
-def show_actions(series, why_selected, boards_selected, builder, options,
+msg = (f"{'Summary of' if is_summary else 'Building'} "
+   f'{commit_str} for {len(selected)} boards')
+msg += (f' ({options.threads} thread{get_plural(options.threads)}, '
+f'{options.jobs} job{get_plural(options.jobs)} per thread)')
+return msg
+
+# pylint: disable=R0913
+def show_actions(series, why_selected, boards_selected, bldr, options,
  board_warnings):
 """Display a list of actions that we would take, if not a dry run.
 
@@ -66,7 +67,7 @@ def show_actions(series, why_selected, boards_selected, 
builder, options,
 the value would be a list of board names.
 boards_selected: Dict of selected boards, key is target name,
 value is Board object
-builder: The builder that will be used to build the commits
+bldr: The builder that will be used to build the commits
 options: Command line options object
 board_warnings: List of warnings obtained from board selected
 """
@@ -79,7 +80,7 @@ def show_actions(series, why_selected, boards_selected, 
builder, options,
 commits = None
 print(get_action_summary(False, commits, boards_selected,
 options))
-print('Build directory: %s' % builder.base_dir)
+print(f'Build directory: {bldr.base_dir}')
 if commits:
 for upto in range(0, len(series.commits), options.step):
 commit = series.commits[upto]
@@ -88,11 +89,11 @@ def show_actions(series, why_selected, boards_selected, 
builder, options,
 print()
 for arg in why_selected:
 if arg != 'all':
-print(arg, ': %d boards' % len(why_selected[arg]))
+print(arg, f': {len(why_selected[arg])} boards')
 if options.verbose:
-print('   %s' % ' '.join(why_selected[arg]))
-print(('Total boards to build for each commit: %d\n' %
-len(why_selected['all'])))
+print(f"   {' '.join(why_selected[arg])}")
+print('Total boards to build for each '
+  f"commit: {len(why_selected['all'])}\n")
 if board_warnings:
 for warning in board_warnings:
 print(col.build(col.YELLOW, warning))
@@ -116,12 +117,26 @@ def show_toolchain_prefix(brds, toolchains):
 tc_set.add(toolchains.Select(brd.arch))
 if len(tc_set) != 1:
 return 'Supplied boards must share one toolchain'
-return False
-tc = tc_set.pop()
-print(tc.GetEnvArgs(toolchain.VAR_CROSS_COMPILE))
+tchain = tc_set.pop()
+print(tchain.GetEnvArgs(toolchain.VAR_CROSS_COMPILE))
 return None
 
 def get_allow_missing(opt_allow, opt_no_allow, num_selected, has_branch):
+"""Figure out whether to allow external blobs
+
+Uses the allow-missing setting and the provided arguments to decide whether
+missing external blobs should be allowed
+
+Args:
+opt_allow (bool): True if --allow-missing flag is set
+opt_no_allow (bool): True if --no-allow-missing flag is set
+num_selected (int): Number of selected board
+has_branch (bool): True if a git branch (to build) has been provided
+
+Returns:
+bool: True to allow missing external blobs, False to produce an error 
if
+external blobs are used
+"""
 allow_missing = False
 am_setting = bsettings.GetGlobalItemValue('allow-missing')
 if