From 168d034c05ac6ba889dd12bafb496e69aab78bfd Mon Sep 17 00:00:00 2001 From: Xyphuz Date: Tue, 10 Jan 2023 22:37:51 +0800 Subject: [PATCH] fix: handle key error during parsing root service --- compose_viz/parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compose_viz/parser.py b/compose_viz/parser.py index a9842ff..127f4ce 100644 --- a/compose_viz/parser.py +++ b/compose_viz/parser.py @@ -28,6 +28,8 @@ class Parser: @staticmethod def compile_dependencies(service_name: str, compose_data: spec.ComposeSpecification) -> List[str]: assert compose_data.services + assert service_name in compose_data.services, f"Service '{service_name}' not found in given compose file." + dependencies = [] for dependency in Parser._unwrap_depends_on(compose_data.services[service_name].depends_on): if dependency: @@ -47,7 +49,7 @@ class Parser: assert compose_data.services is not None, "No services found, aborting." - root_dependencies: List[str] = list() + root_dependencies: List[str] = [] if root_service: root_dependencies = Parser.compile_dependencies(root_service, compose_data) root_dependencies.append(root_service)