chore(internal): add Sequence related utils

This commit is contained in:
stainless-app[bot] 2025-08-30 02:02:16 +00:00
parent 82c499048e
commit 002bf6d3d6
4 changed files with 50 additions and 2 deletions

View file

@ -4,7 +4,7 @@ import os
import inspect
import traceback
import contextlib
from typing import Any, TypeVar, Iterator, cast
from typing import Any, TypeVar, Iterator, Sequence, cast
from datetime import date, datetime
from typing_extensions import Literal, get_args, get_origin, assert_type
@ -15,6 +15,7 @@ from opencode_ai._utils import (
is_list_type,
is_union_type,
extract_type_arg,
is_sequence_type,
is_annotated_type,
is_type_alias_type,
)
@ -71,6 +72,13 @@ def assert_matches_type(
if is_list_type(type_):
return _assert_list_type(type_, value)
if is_sequence_type(type_):
assert isinstance(value, Sequence)
inner_type = get_args(type_)[0]
for entry in value: # type: ignore
assert_type(inner_type, entry) # type: ignore
return
if origin == str:
assert isinstance(value, str)
elif origin == int: