From 9162fe6438b72f9467a22958c71f491c127484e8 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 19 May 2025 18:28:14 +0300 Subject: [PATCH 1/4] Remove unused code Signed-off-by: Povilas Kanapickas --- podman_compose.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/podman_compose.py b/podman_compose.py index 0bf19a6..85853b7 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -2156,8 +2156,6 @@ class PodmanCompose: service_names = [name for _, name in service_names] resolve_extends(services, service_names, self.environ) flat_deps(services) - service_names = sorted([(len(srv["_deps"]), name) for name, srv in services.items()]) - service_names = [name for _, name in service_names] nets = compose.get("networks", {}) if not nets: nets["default"] = None From 8aeeafb98c3e2a1e4d57692dd3814e18c11c64d3 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 19 May 2025 18:28:15 +0300 Subject: [PATCH 2/4] Rename redefined variables Signed-off-by: Povilas Kanapickas --- podman_compose.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/podman_compose.py b/podman_compose.py index 85853b7..9314e19 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -455,13 +455,13 @@ def mount_desc_to_mount_args(compose, mount_desc, srv_name, cnt_name): # pylint selinux = bind_opts.get("selinux") if selinux is not None: opts.append(selinux) - opts = ",".join(opts) + opts_str = ",".join(opts) if mount_type == "bind": - return f"type=bind,source={source},destination={target},{opts}".rstrip(",") + return f"type=bind,source={source},destination={target},{opts_str}".rstrip(",") if mount_type == "volume": - return f"type=volume,source={source},destination={target},{opts}".rstrip(",") + return f"type=volume,source={source},destination={target},{opts_str}".rstrip(",") if mount_type == "tmpfs": - return f"type=tmpfs,destination={target},{opts}".rstrip(",") + return f"type=tmpfs,destination={target},{opts_str}".rstrip(",") raise ValueError("unknown mount type:" + mount_type) @@ -2002,9 +2002,9 @@ class PodmanCompose: def _parse_compose_file(self): args = self.global_args # cmd = args.command - dirname = os.environ.get("COMPOSE_PROJECT_DIR") - if dirname and os.path.isdir(dirname): - os.chdir(dirname) + project_dir = os.environ.get("COMPOSE_PROJECT_DIR") + if project_dir and os.path.isdir(project_dir): + os.chdir(project_dir) pathsep = os.environ.get("COMPOSE_PATH_SEPARATOR", os.pathsep) if not args.file: default_str = os.environ.get("COMPOSE_FILE") @@ -3044,17 +3044,16 @@ async def compose_up(compose: PodmanCompose, args): for t in tasks: if not _task_cancelled(t): t.cancel() - t: Task + t_: Task exiting = True if first_failed_task: # Matches docker-compose behaviour, where the exit code of the task that triggered # the cancellation is always propagated when aborting on failure exit_code = first_failed_task.result() else: - for t in done: - if t.get_name() == exit_code_from: - exit_code = t.result() - + for t_ in done: + if t_.get_name() == exit_code_from: + exit_code = t_.result() return exit_code From 02166f584af8eda05401cf0f10bffb1ac3dcc008 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 19 May 2025 18:28:16 +0300 Subject: [PATCH 3/4] Use more standard call to list.append Signed-off-by: Povilas Kanapickas --- podman_compose.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/podman_compose.py b/podman_compose.py index 9314e19..c50d10c 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -2674,7 +2674,7 @@ def container_to_build_args(compose, cnt, args, path_exists, cleanup_callbacks=N os.remove(dockerfile) if cleanup_callbacks is not None: - list.append(cleanup_callbacks, cleanup_temp_dockfile) + cleanup_callbacks.append(cleanup_temp_dockfile) build_args = [] From 39e21d8c11617a3828ac5acf1acf7d1bc1551c40 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 19 May 2025 18:28:17 +0300 Subject: [PATCH 4/4] Remove extraneous await on non-async function Signed-off-by: Povilas Kanapickas --- podman_compose.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/podman_compose.py b/podman_compose.py index c50d10c..4fe044e 100755 --- a/podman_compose.py +++ b/podman_compose.py @@ -2504,7 +2504,7 @@ async def compose_wait(compose, args): # pylint: disable=unused-argument containers = [cnt["name"] for cnt in compose.containers] cmd_args = ["--"] cmd_args.extend(containers) - await compose.podman.exec([], "wait", cmd_args) + compose.podman.exec([], "wait", cmd_args) @cmd_run(podman_compose, "systemd")