Skip to content

Commit aebcb62

Browse files
cristipufuclaude
andcommitted
fix: resolve mypy errors with DebugBridgeProtocol extending UiPathDebugProtocol
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cb4997d commit aebcb62

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

src/uipath/dev/services/run_service.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import json
66
import traceback
77
from datetime import datetime
8-
from typing import Any, Callable, cast
8+
from typing import Any, Callable, Literal, Protocol, cast
99

1010
from pydantic import BaseModel
1111
from uipath.core.tracing import UiPathTraceManager
@@ -18,7 +18,11 @@
1818
UiPathRuntimeStatus,
1919
UiPathStreamOptions,
2020
)
21-
from uipath.runtime.debug import UiPathDebugProtocol, UiPathDebugRuntime
21+
from uipath.runtime.debug import (
22+
UiPathBreakpointResult,
23+
UiPathDebugProtocol,
24+
UiPathDebugRuntime,
25+
)
2226
from uipath.runtime.errors import UiPathErrorContract, UiPathRuntimeError
2327
from uipath.runtime.events import UiPathRuntimeMessageEvent, UiPathRuntimeStateEvent
2428

@@ -30,7 +34,23 @@
3034
LogCallback = Callable[[LogData], None]
3135
TraceCallback = Callable[[TraceData], None]
3236
ChatCallback = Callable[[ChatData], None]
33-
DebugBridgeFactory = Callable[[ExecutionMode], UiPathDebugProtocol]
37+
38+
39+
class DebugBridgeProtocol(UiPathDebugProtocol, Protocol):
40+
"""Extended debug bridge protocol with control methods and callbacks."""
41+
42+
on_execution_started: Callable[[], None] | None
43+
on_state_update: Callable[[UiPathRuntimeStateEvent], None] | None
44+
on_breakpoint_hit: Callable[[UiPathBreakpointResult], None] | None
45+
on_execution_completed: Callable[[UiPathRuntimeResult], None] | None
46+
on_execution_error: Callable[[str], None] | None
47+
48+
def resume(self, resume_data: Any) -> None: ...
49+
def quit(self) -> None: ...
50+
def set_breakpoints(self, breakpoints: list[str] | Literal["*"]) -> None: ...
51+
52+
53+
DebugBridgeFactory = Callable[[ExecutionMode], DebugBridgeProtocol]
3454

3555

3656
class RunService:
@@ -71,7 +91,7 @@ def __init__(
7191
batch=False,
7292
)
7393

74-
self.debug_bridges: dict[str, UiPathDebugProtocol] = {}
94+
self.debug_bridges: dict[str, DebugBridgeProtocol] = {}
7595

7696
def register_run(self, run: ExecutionRun) -> None:
7797
"""Register a new run and emit an initial update."""
@@ -276,7 +296,7 @@ def handle_trace(self, trace_data: TraceData) -> None:
276296
if self.on_trace is not None:
277297
self.on_trace(trace_data)
278298

279-
def get_debug_bridge(self, run_id: str) -> UiPathDebugProtocol | None:
299+
def get_debug_bridge(self, run_id: str) -> DebugBridgeProtocol | None:
280300
"""Get the debug bridge for a run."""
281301
return self.debug_bridges.get(run_id)
282302

0 commit comments

Comments
 (0)