From 695b26d5d24be5e90de4ecef12ead0e74a90addc Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Mon, 16 Mar 2026 01:42:10 +0000 Subject: [PATCH] fix(deployment): resolve run() name shadowing in CLI modules The module entry point `run = run_cmd` shadowed the imported subprocess helper `run` from cli.helpers, causing TypeError on dispatch. Import as `run_proc` and use a proper wrapper function for the module entry point. Co-Authored-By: Claude Opus 4.6 (1M context) --- deployment/cli/artifactory_init.py | 5 +++-- deployment/cli/build_apps.py | 12 +++++++----- deployment/cli/build_testcontainers.py | 15 ++++++++------- deployment/cli/nexus_init.py | 23 ++++++++++++----------- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/deployment/cli/artifactory_init.py b/deployment/cli/artifactory_init.py index 47eaa7686..32182e9b0 100644 --- a/deployment/cli/artifactory_init.py +++ b/deployment/cli/artifactory_init.py @@ -4,7 +4,7 @@ import argparse import os import subprocess import time -from cli.helpers import curl_status, run +from cli.helpers import curl_status, run as run_proc REPO_CONFIGS = [ @@ -114,4 +114,5 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: return 0 -run = run_cmd +def run(args, config): + return run_cmd(args, config) diff --git a/deployment/cli/build_apps.py b/deployment/cli/build_apps.py index 322a9e321..dc3f769e9 100644 --- a/deployment/cli/build_apps.py +++ b/deployment/cli/build_apps.py @@ -5,7 +5,7 @@ import time from cli.helpers import ( BASE_DIR, PROJECT_ROOT, GREEN, YELLOW, NC, docker_compose, docker_image_exists, log_err, log_info, log_ok, log_warn, - pull_with_retry, resolve_services, run, + pull_with_retry, resolve_services, run as run_proc, ) @@ -17,7 +17,7 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: node_tag = base_images["node-deps"]["tag"] if not docker_image_exists(node_tag): log_warn(f"Building {node_tag} (required by all Node.js frontends)...") - result = run([ + result = run_proc([ "docker", "build", "-f", str(BASE_DIR / base_images["node-deps"]["dockerfile"]), "-t", node_tag, str(PROJECT_ROOT), @@ -78,7 +78,7 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: all_ok = True for svc in services: log_info(f"Building {svc}...") - result = run(docker_compose("build", svc)) + result = run_proc(docker_compose("build", svc)) if result.returncode != 0: log_err(f"Failed: {svc}") all_ok = False @@ -89,7 +89,7 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: break else: log_info("Parallel build (uses more RAM)...") - result = run(docker_compose("build", "--parallel", *services)) + result = run_proc(docker_compose("build", "--parallel", *services)) if result.returncode == 0: build_ok = True break @@ -109,4 +109,6 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: # Module entry point — called by loader.dispatch() -run = run_cmd +# NOTE: must not shadow the imported `run` from cli.helpers +def run(args, config): + return run_cmd(args, config) diff --git a/deployment/cli/build_testcontainers.py b/deployment/cli/build_testcontainers.py index 67ecbf0c1..8248f56d0 100644 --- a/deployment/cli/build_testcontainers.py +++ b/deployment/cli/build_testcontainers.py @@ -3,7 +3,7 @@ import argparse import os import shutil -from cli.helpers import PROJECT_ROOT, log_err, log_info, log_ok, run, run_check +from cli.helpers import PROJECT_ROOT, log_err, log_info, log_ok, run as run_proc, run_check def run_cmd(args: argparse.Namespace, config: dict) -> int: @@ -17,14 +17,14 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: if not shutil.which(tool): log_err(f"{tool} not found. Install: {install_msg}") return 1 - run([tool, "version" if tool == "go" else "--version"]) + run_proc([tool, "version" if tool == "go" else "--version"]) log_info("Configuring Nexus Conan remote...") - run(["conan", "remote", "add", "nexus", nexus_url, "--force"]) + run_proc(["conan", "remote", "add", "nexus", nexus_url, "--force"]) run_check(["conan", "remote", "login", "nexus", nexus_user, "--password", nexus_pass]) - run(["conan", "remote", "disable", "conancenter"]) - run(["conan", "remote", "enable", "conancenter"]) - run(["conan", "remote", "update", "nexus", "--index", "0"]) + run_proc(["conan", "remote", "disable", "conancenter"]) + run_proc(["conan", "remote", "enable", "conancenter"]) + run_proc(["conan", "remote", "update", "nexus", "--index", "0"]) if not args.skip_native: log_info("Building testcontainers-native/0.1.0 (C shared library)...") @@ -53,4 +53,5 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: return 0 -run = run_cmd +def run(args, config): + return run_cmd(args, config) diff --git a/deployment/cli/nexus_init.py b/deployment/cli/nexus_init.py index 370af0e2c..343760276 100644 --- a/deployment/cli/nexus_init.py +++ b/deployment/cli/nexus_init.py @@ -4,7 +4,7 @@ import argparse import json import os import subprocess -from cli.helpers import curl_status, log_err, run +from cli.helpers import curl_status, log_err, run as run_proc def run_cmd(args: argparse.Namespace, config: dict) -> int: @@ -42,16 +42,16 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: return 1 # Enable anonymous access - run(["curl", "-sf", "-X", "PUT", f"{nexus_url}/service/rest/v1/security/anonymous", - "-u", auth, "-H", "Content-Type: application/json", - "-d", '{"enabled":true,"userId":"anonymous","realmName":"NexusAuthorizingRealm"}']) + run_proc(["curl", "-sf", "-X", "PUT", f"{nexus_url}/service/rest/v1/security/anonymous", + "-u", auth, "-H", "Content-Type: application/json", + "-d", '{"enabled":true,"userId":"anonymous","realmName":"NexusAuthorizingRealm"}']) nlog("Anonymous access enabled") if not args.ci: # Docker + npm token realms - run(["curl", "-sf", "-X", "PUT", f"{nexus_url}/service/rest/v1/security/realms/active", - "-u", auth, "-H", "Content-Type: application/json", - "-d", '["NexusAuthenticatingRealm","DockerToken","NpmToken"]']) + run_proc(["curl", "-sf", "-X", "PUT", f"{nexus_url}/service/rest/v1/security/realms/active", + "-u", auth, "-H", "Content-Type: application/json", + "-d", '["NexusAuthenticatingRealm","DockerToken","NpmToken"]']) nlog("Docker + npm Bearer Token realms enabled") # Docker hosted repo @@ -75,9 +75,9 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: return 1 else: # CI: npm token realm only - run(["curl", "-sf", "-X", "PUT", f"{nexus_url}/service/rest/v1/security/realms/active", - "-u", auth, "-H", "Content-Type: application/json", - "-d", '["NexusAuthenticatingRealm","NpmToken"]']) + run_proc(["curl", "-sf", "-X", "PUT", f"{nexus_url}/service/rest/v1/security/realms/active", + "-u", auth, "-H", "Content-Type: application/json", + "-d", '["NexusAuthenticatingRealm","NpmToken"]']) # npm repos (hosted, proxy, group) npm_repos = [ @@ -130,4 +130,5 @@ def run_cmd(args: argparse.Namespace, config: dict) -> int: return 0 -run = run_cmd +def run(args, config): + return run_cmd(args, config)