Skip to content

Commit

Permalink
osbuild: tweak build() to be mypy clean
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mvo5 committed Jan 13, 2025
1 parent d316007 commit 8b88b3d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions osbuild/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 8b88b3d

Please sign in to comment.