Skip to content

Commit 88dc81c

Browse files
hack: remove unnecessary uses of lambda
I find lambda to be a bit of an unpleasant thing and try to remove it when possible. Since all uses of lambda in this code are calling the same function we can remove the function (and unchanging) argument and have the variable section map to the run function's remaining kwargs. Signed-off-by: John Mulligan <[email protected]>
1 parent a45b646 commit 88dc81c

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

hack/build-image

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,33 +217,31 @@ def container_build(cli, target):
217217
# architectures, and we must ensure we start with a fresh builder
218218
# that does not contain any images from previous builds.
219219
tasks.append(
220-
lambda: run(cli, args + ["rm", target.flat_name()], check=False)
220+
{"cmd": args + ["rm", target.flat_name()], "check": False}
221221
)
222222
tasks.append(
223-
lambda: run(
224-
cli,
225-
args + ["create", f"--name={target.flat_name()}"],
226-
check=True,
227-
)
223+
{
224+
"cmd": args + ["create", f"--name={target.flat_name()}"],
225+
"check": True,
226+
}
228227
)
229228

230229
tasks.append(
231-
lambda: run(
232-
cli,
233-
args
230+
{
231+
"cmd": args
234232
+ [
235233
"build",
236234
f"--builder={target.flat_name()}",
237235
f"--platform=linux/{target.arch}",
238236
"--load",
239237
]
240238
+ create_common_container_engine_args(cli, target),
241-
check=True,
242-
)
239+
"check": True,
240+
}
243241
)
244242

245243
tasks.append(
246-
lambda: run(cli, args + ["rm", target.flat_name()], check=True)
244+
{"cmd": args + ["rm", target.flat_name()], "check": True}
247245
)
248246
else:
249247
args = [eng, "build"]
@@ -257,15 +255,15 @@ def container_build(cli, target):
257255
args += [f"--arch={target.arch}"]
258256

259257
tasks.append(
260-
lambda: run(
261-
cli,
262-
args + create_common_container_engine_args(cli, target),
263-
check=True,
264-
)
258+
{
259+
"cmd": args
260+
+ create_common_container_engine_args(cli, target),
261+
"check": True,
262+
}
265263
)
266264

267265
for task in tasks:
268-
task()
266+
run(cli, **task)
269267

270268

271269
def create_common_container_engine_args(cli, target):

0 commit comments

Comments
 (0)