fix: add from __future__ import annotations to workspace_manager.py

Fixes NameError: ToolInstance not defined at runtime because
type annotations are evaluated at class definition time.
Deferring annotation evaluation with __future__ annotations
keeps TYPE_CHECKING imports from causing runtime crashes.

Also includes ruff formatting cleanup on workspace-related files.
This commit is contained in:
2026-05-31 23:41:45 +02:00
parent 5bba2bbd92
commit a5d64d1859
15 changed files with 831 additions and 699 deletions
+1
View File
@@ -1684,6 +1684,7 @@ async def start_instance(
repo_path = ""
if instance.workspace_id:
from src.models.workspace import Workspace as WorkspaceModel
workspace = await session.get(WorkspaceModel, instance.workspace_id)
if workspace:
repo_path = workspace.path
+4 -4
View File
@@ -108,7 +108,9 @@ async def create_workspace(
"branch": workspace.branch,
"path": workspace.path,
"status": workspace.status,
"created_at": workspace.created_at.isoformat() if workspace.created_at else None,
"created_at": workspace.created_at.isoformat()
if workspace.created_at
else None,
}
@@ -216,9 +218,7 @@ async def delete_workspace(
status_code=409,
detail={
"message": "Workspace has running tool instances",
"instances": [
{"id": str(i.id), "name": i.name} for i in exc.instances
],
"instances": [{"id": str(i.id), "name": i.name} for i in exc.instances],
},
) from exc
except Exception as exc:
+3 -3
View File
@@ -1,5 +1,7 @@
"""Workspace lifecycle management service."""
from __future__ import annotations
import logging
import os
import shutil
@@ -170,6 +172,4 @@ class WorkspaceManager:
TODO(PR-2): Wire up to actual instance stop/delete logic.
For now, this is a placeholder.
"""
logger.warning(
"Placeholder: stopping and deleting instance %s", instance.id
)
logger.warning("Placeholder: stopping and deleting instance %s", instance.id)