Skip to content

Commit aa3032a

Browse files
committed
fix: remove typing optional union
1 parent bc78e7a commit aa3032a

File tree

11 files changed

+55
-63
lines changed

11 files changed

+55
-63
lines changed

src/uipath/dev/_demo/mock_context_runtime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import logging
3-
from typing import Any, AsyncGenerator, Optional
3+
from typing import Any, AsyncGenerator
44

55
from opentelemetry import trace
66
from uipath.runtime import (
@@ -57,8 +57,8 @@ async def get_schema(self) -> UiPathRuntimeSchema:
5757

5858
async def execute(
5959
self,
60-
input: Optional[dict[str, Any]] = None,
61-
options: Optional[UiPathExecuteOptions] = None,
60+
input: dict[str, Any] | None = None,
61+
options: UiPathExecuteOptions | None = None,
6262
) -> UiPathRuntimeResult:
6363
from uipath.runtime.debug import UiPathBreakpointResult
6464

@@ -451,8 +451,8 @@ async def execute(
451451

452452
async def stream(
453453
self,
454-
input: Optional[dict[str, Any]] = None,
455-
options: Optional[UiPathStreamOptions] = None,
454+
input: dict[str, Any] | None = None,
455+
options: UiPathStreamOptions | None = None,
456456
) -> AsyncGenerator[UiPathRuntimeEvent, None]:
457457
logger.info("MockRuntime: stream() invoked")
458458
print("[MockRuntime] stream() invoked")

src/uipath/dev/_demo/mock_greeting_runtime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import logging
3-
from typing import Any, AsyncGenerator, Optional
3+
from typing import Any, AsyncGenerator
44

55
from opentelemetry import trace
66
from uipath.runtime import (
@@ -59,8 +59,8 @@ async def get_schema(self) -> UiPathRuntimeSchema:
5959

6060
async def execute(
6161
self,
62-
input: Optional[dict[str, Any]] = None,
63-
options: Optional[UiPathExecuteOptions] = None,
62+
input: dict[str, Any] | None = None,
63+
options: UiPathExecuteOptions | None = None,
6464
) -> UiPathRuntimeResult:
6565
payload = input or {}
6666
name = str(payload.get("name", "world")).strip() or "world"
@@ -121,8 +121,8 @@ async def execute(
121121

122122
async def stream(
123123
self,
124-
input: Optional[dict[str, Any]] = None,
125-
options: Optional[UiPathStreamOptions] = None,
124+
input: dict[str, Any] | None = None,
125+
options: UiPathStreamOptions | None = None,
126126
) -> AsyncGenerator[UiPathRuntimeEvent, None]:
127127
logger.info("GreetingRuntime: stream() invoked")
128128
yield await self.execute(input=input, options=options)

src/uipath/dev/_demo/mock_numbers_runtime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import logging
3-
from typing import Any, AsyncGenerator, Optional
3+
from typing import Any, AsyncGenerator
44

55
from opentelemetry import trace
66
from uipath.runtime import (
@@ -58,8 +58,8 @@ async def get_schema(self) -> UiPathRuntimeSchema:
5858

5959
async def execute(
6060
self,
61-
input: Optional[dict[str, Any]] = None,
62-
options: Optional[UiPathExecuteOptions] = None,
61+
input: dict[str, Any] | None = None,
62+
options: UiPathExecuteOptions | None = None,
6363
) -> UiPathRuntimeResult:
6464
payload = input or {}
6565
numbers = payload.get("numbers") or []
@@ -134,8 +134,8 @@ async def execute(
134134

135135
async def stream(
136136
self,
137-
input: Optional[dict[str, Any]] = None,
138-
options: Optional[UiPathStreamOptions] = None,
137+
input: dict[str, Any] | None = None,
138+
options: UiPathStreamOptions | None = None,
139139
) -> AsyncGenerator[UiPathRuntimeEvent, None]:
140140
logger.info("NumberAnalyticsRuntime: stream() invoked")
141141
yield await self.execute(input=input, options=options)

src/uipath/dev/_demo/mock_support_runtime.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
import logging
3-
from typing import Any, AsyncGenerator, Optional
3+
from typing import Any, AsyncGenerator
44

55
from opentelemetry import trace
66
from uipath.runtime import (
@@ -57,8 +57,8 @@ async def get_schema(self) -> UiPathRuntimeSchema:
5757

5858
async def execute(
5959
self,
60-
input: Optional[dict[str, Any]] = None,
61-
options: Optional[UiPathExecuteOptions] = None,
60+
input: dict[str, Any] | None = None,
61+
options: UiPathExecuteOptions | None = None,
6262
) -> UiPathRuntimeResult:
6363
payload = input or {}
6464
message = str(payload.get("message", "")).strip()
@@ -136,8 +136,8 @@ async def execute(
136136

137137
async def stream(
138138
self,
139-
input: Optional[dict[str, Any]] = None,
140-
options: Optional[UiPathStreamOptions] = None,
139+
input: dict[str, Any] | None = None,
140+
options: UiPathStreamOptions | None = None,
141141
) -> AsyncGenerator[UiPathRuntimeEvent, None]:
142142
logger.info("SupportChatRuntime: stream() invoked")
143143
yield await self.execute(input=input, options=options)

src/uipath/dev/models/execution.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
from datetime import datetime
5-
from typing import Any, Optional, Union
5+
from typing import Any
66
from uuid import uuid4
77

88
from rich.text import Text
@@ -17,7 +17,7 @@ class ExecutionRun:
1717
def __init__(
1818
self,
1919
entrypoint: str,
20-
input_data: Union[dict[str, Any]],
20+
input_data: dict[str, Any],
2121
conversational: bool = False,
2222
debug: bool = False,
2323
):
@@ -27,14 +27,14 @@ def __init__(
2727
self.input_data = input_data
2828
self.conversational = conversational
2929
self.debug = debug
30-
self.resume_data: Optional[dict[str, Any]] = None
31-
self.output_data: Optional[dict[str, Any]] = None
30+
self.resume_data: dict[str, Any] | None = None
31+
self.output_data: dict[str, Any] | None = None
3232
self.start_time = datetime.now()
33-
self.end_time: Optional[datetime] = None
33+
self.end_time: datetime | None = None
3434
self.status = "pending" # pending, running, completed, failed, suspended
3535
self.traces: list[TraceMessage] = []
3636
self.logs: list[LogMessage] = []
37-
self.error: Optional[UiPathErrorContract] = None
37+
self.error: UiPathErrorContract | None = None
3838

3939
@property
4040
def duration(self) -> str:

src/uipath/dev/models/messages.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Messages used for inter-component communication in the UiPath Developer Console."""
22

33
from datetime import datetime
4-
from typing import Any, Optional, Union
4+
from typing import Any
55

66
from rich.console import RenderableType
77
from textual.message import Message
@@ -14,8 +14,8 @@ def __init__(
1414
self,
1515
run_id: str,
1616
level: str,
17-
message: Union[str, RenderableType],
18-
timestamp: Optional[datetime] = None,
17+
message: str | RenderableType,
18+
timestamp: datetime | None = None,
1919
):
2020
"""Initialize a LogMessage instance."""
2121
self.run_id = run_id
@@ -33,12 +33,12 @@ def __init__(
3333
run_id: str,
3434
span_name: str,
3535
span_id: str,
36-
parent_span_id: Optional[str] = None,
37-
trace_id: Optional[str] = None,
36+
parent_span_id: str | None = None,
37+
trace_id: str | None = None,
3838
status: str = "running",
39-
duration_ms: Optional[float] = None,
40-
timestamp: Optional[datetime] = None,
41-
attributes: Optional[dict[str, Any]] = None,
39+
duration_ms: float | None = None,
40+
timestamp: datetime | None = None,
41+
attributes: dict[str, Any] | None = None,
4242
):
4343
"""Initialize a TraceMessage instance."""
4444
self.run_id = run_id

src/uipath/dev/services/debug_bridge.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import asyncio
44
import logging
5-
from typing import Any, Callable, Literal, Optional
5+
from typing import Any, Callable, Literal
66

77
from uipath.runtime.debug import UiPathBreakpointResult, UiPathDebugQuitError
88
from uipath.runtime.events import UiPathRuntimeStateEvent
@@ -22,15 +22,11 @@ def __init__(self):
2222
self._breakpoints: list[str] | Literal["*"] = "*" # Default: step mode
2323

2424
# Callbacks to UI
25-
self.on_execution_started: Optional[Callable[[], None]] = None
26-
self.on_state_update: Optional[Callable[[UiPathRuntimeStateEvent], None]] = None
27-
self.on_breakpoint_hit: Optional[Callable[[UiPathBreakpointResult], None]] = (
28-
None
29-
)
30-
self.on_execution_completed: Optional[Callable[[UiPathRuntimeResult], None]] = (
31-
None
32-
)
33-
self.on_execution_error: Optional[Callable[[str], None]] = None
25+
self.on_execution_started: Callable[[], None] | None = None
26+
self.on_state_update: Callable[[UiPathRuntimeStateEvent], None] | None = None
27+
self.on_breakpoint_hit: Callable[[UiPathBreakpointResult], None] | None = None
28+
self.on_execution_completed: Callable[[UiPathRuntimeResult], None] | None = None
29+
self.on_execution_error: Callable[[str], None] | None = None
3430

3531
async def connect(self) -> None:
3632
"""Establish connection to debugger."""

src/uipath/dev/services/run_service.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import traceback
66
from datetime import datetime
7-
from typing import Any, Callable, Dict, Optional
7+
from typing import Any, Callable
88

99
from pydantic import BaseModel
1010
from uipath.core.tracing import UiPathTraceManager
@@ -40,14 +40,14 @@ def __init__(
4040
self,
4141
runtime_factory: UiPathRuntimeFactoryProtocol,
4242
trace_manager: UiPathTraceManager,
43-
on_run_updated: Optional[RunUpdatedCallback] = None,
44-
on_log: Optional[LogCallback] = None,
45-
on_trace: Optional[TraceCallback] = None,
43+
on_run_updated: RunUpdatedCallback | None = None,
44+
on_log: LogCallback | None = None,
45+
on_trace: TraceCallback | None = None,
4646
) -> None:
4747
"""Initialize RunService with runtime factory and trace manager."""
4848
self.runtime_factory = runtime_factory
4949
self.trace_manager = trace_manager
50-
self.runs: Dict[str, ExecutionRun] = {}
50+
self.runs: dict[str, ExecutionRun] = {}
5151

5252
self.on_run_updated = on_run_updated
5353
self.on_log = on_log
@@ -68,7 +68,7 @@ def register_run(self, run: ExecutionRun) -> None:
6868
self.runs[run.id] = run
6969
self._emit_run_updated(run)
7070

71-
def get_run(self, run_id: str) -> Optional[ExecutionRun]:
71+
def get_run(self, run_id: str) -> ExecutionRun | None:
7272
"""Get a registered run."""
7373
return self.runs.get(run_id)
7474

@@ -78,7 +78,7 @@ async def execute(self, run: ExecutionRun) -> None:
7878
This is the extracted version of the old `_execute_runtime` method.
7979
"""
8080
try:
81-
execution_input: Optional[dict[str, Any]] = {}
81+
execution_input: dict[str, Any] | None = {}
8282
execution_options: UiPathExecuteOptions = UiPathExecuteOptions()
8383

8484
if run.status == "suspended":
@@ -239,7 +239,7 @@ def handle_trace(self, trace_msg: TraceMessage) -> None:
239239
if self.on_trace is not None:
240240
self.on_trace(trace_msg)
241241

242-
def get_debug_bridge(self, run_id: str) -> Optional[TextualDebugBridge]:
242+
def get_debug_bridge(self, run_id: str) -> TextualDebugBridge | None:
243243
"""Get the debug bridge for a run."""
244244
return self.debug_bridges.get(run_id)
245245

src/uipath/dev/ui/panels/new_run_panel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Panel for creating new runs with entrypoint selection and JSON input."""
22

33
import json
4-
from typing import Any, Dict, Tuple, cast
4+
from typing import Any, Tuple, cast
55

66
from textual.app import ComposeResult
77
from textual.containers import Container, Horizontal, Vertical
@@ -96,7 +96,7 @@ def __init__(
9696

9797
self.entrypoints: list[str] = []
9898

99-
self.entrypoint_schemas: Dict[str, dict[str, Any]] = {}
99+
self.entrypoint_schemas: dict[str, dict[str, Any]] = {}
100100

101101
self.conversational: bool = False
102102
self.initial_input: str = "{}"

src/uipath/dev/ui/panels/run_details_panel.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Panel for displaying execution run details, traces, and logs."""
22

3-
from typing import Optional
4-
53
from textual.app import ComposeResult
64
from textual.containers import Container, Horizontal, Vertical
75
from textual.reactive import reactive
@@ -82,7 +80,7 @@ def show_span_details(self, trace_msg: TraceMessage):
8280
class RunDetailsPanel(Container):
8381
"""Panel showing traces and logs for selected run with tabbed interface."""
8482

85-
current_run: reactive[Optional[ExecutionRun]] = reactive(None)
83+
current_run: reactive[ExecutionRun | None] = reactive(None)
8684

8785
def __init__(self, **kwargs):
8886
"""Initialize RunDetailsPanel."""
@@ -145,7 +143,7 @@ def compose(self) -> ComposeResult:
145143
)
146144

147145
def watch_current_run(
148-
self, old_value: Optional[ExecutionRun], new_value: Optional[ExecutionRun]
146+
self, old_value: ExecutionRun | None, new_value: ExecutionRun | None
149147
):
150148
"""Watch for changes to the current run."""
151149
if new_value is not None:

0 commit comments

Comments
 (0)