From 8b88b3decde8a72344c68fdd362c6cfd7851fe24 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 13 Jan 2025 17:04:56 +0100 Subject: [PATCH] osbuild: tweak build() to be mypy clean This commit tweaks build() to be mypy clean without the need to call assert. This drops the map() and instead we use the existing dict-like access of the manifest to get the pipeline. In practise this should not happen but lets be prepared. Note that a small tweak for the error is needed to make it clear what is happening. Thanks to Simon for raising this. --- osbuild/pipeline.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osbuild/pipeline.py b/osbuild/pipeline.py index 0a08a3cc0..0f7f9f43d 100644 --- a/osbuild/pipeline.py +++ b/osbuild/pipeline.py @@ -518,8 +518,8 @@ def build(self, store, pipelines, monitor, libdir, debug_break="", stage_timeout """ results = {"success": True} - for pl in map(self.get, pipelines): - assert pl is not None + for name_or_id in pipelines: + pl = self[name_or_id] res = pl.run(store, monitor, libdir, debug_break, stage_timeout) results[pl.id] = res if not res["success"]: @@ -569,7 +569,7 @@ def __getitem__(self, name_or_id: str) -> Pipeline: pl = self.get(name_or_id) if pl: return pl - raise KeyError(f"'{name_or_id}' not found") + raise KeyError(f"'{name_or_id}' not found in manifest pipelines: {list(self.pipelines.keys())}") def __iter__(self) -> Iterator[Pipeline]: return iter(self.pipelines.values())