Update Optional[x] -> x | None and Union[x, y] to x | y (#26633)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-10-12 09:51:31 -07:00
committed by GitHub
parent 9bb38130cb
commit 8fcaaf6a16
944 changed files with 9490 additions and 10121 deletions
@@ -4,7 +4,7 @@
import contextlib
import json
from collections.abc import Sequence
from typing import Any, Optional, Union
from typing import Any
import regex as re
@@ -58,7 +58,7 @@ class Step3ToolParser(ToolParser):
@staticmethod
def _parse_steptml_invoke(
action_text: str,
) -> tuple[Optional[str], Optional[dict[str, str]]]:
) -> tuple[str | None, dict[str, str] | None]:
func_name_match = re.search(r'<steptml:invoke name="([^"]+)">', action_text)
if not func_name_match:
return None, None
@@ -117,7 +117,7 @@ class Step3ToolParser(ToolParser):
current_token_ids: Sequence[int],
delta_token_ids: Sequence[int],
request: ChatCompletionRequest,
) -> Union[DeltaMessage, None]:
) -> DeltaMessage | None:
# The main loop processes the stream from the last known position.
while True:
if self.position >= len(current_text):