Skip to content

Commit 1245c0d

Browse files
committed
Fix EM101: assign exception messages to variables before raising
1 parent 7f2dbdb commit 1245c0d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/seclab_taskflows/mcp_servers/container_shell.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333
def _start_container() -> str:
3434
"""Start the Docker container and return its name."""
3535
if not CONTAINER_IMAGE:
36-
raise RuntimeError("CONTAINER_IMAGE is not set — cannot start container")
36+
msg = "CONTAINER_IMAGE is not set — cannot start container"
37+
raise RuntimeError(msg)
3738
if CONTAINER_WORKSPACE and ":" in CONTAINER_WORKSPACE:
38-
raise RuntimeError(f"CONTAINER_WORKSPACE must not contain a colon: {CONTAINER_WORKSPACE!r}")
39+
msg = f"CONTAINER_WORKSPACE must not contain a colon: {CONTAINER_WORKSPACE!r}"
40+
raise RuntimeError(msg)
3941
name = f"seclab-shell-{uuid.uuid4().hex[:8]}"
4042
cmd = ["docker", "run", "-d", "--rm", "--name", name]
4143
if CONTAINER_WORKSPACE:
@@ -44,7 +46,8 @@ def _start_container() -> str:
4446
logging.debug(f"Starting container: {' '.join(cmd)}")
4547
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
4648
if result.returncode != 0:
47-
raise RuntimeError(f"docker run failed: {result.stderr.strip()}")
49+
msg = f"docker run failed: {result.stderr.strip()}"
50+
raise RuntimeError(msg)
4851
logging.debug(f"Container started: {name}")
4952
return name
5053

0 commit comments

Comments
 (0)