Skip to content

Commit 6155c3f

Browse files
feat(types): replace List[str] with SequenceNotStr in params
1 parent 601cf7f commit 6155c3f

5 files changed

Lines changed: 21 additions & 11 deletions

File tree

src/parallel/_utils/_transform.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
lru_cache,
1717
is_mapping,
1818
is_iterable,
19+
is_sequence,
1920
)
2021
from .._files import is_base64_file_input
2122
from ._typing import (
@@ -24,6 +25,7 @@
2425
extract_type_arg,
2526
is_iterable_type,
2627
is_required_type,
28+
is_sequence_type,
2729
is_annotated_type,
2830
strip_annotated_type,
2931
)
@@ -184,6 +186,8 @@ def _transform_recursive(
184186
(is_list_type(stripped_type) and is_list(data))
185187
# Iterable[T]
186188
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
189+
# Sequence[T]
190+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
187191
):
188192
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
189193
# intended as an iterable, so we don't transform it.
@@ -346,6 +350,8 @@ async def _async_transform_recursive(
346350
(is_list_type(stripped_type) and is_list(data))
347351
# Iterable[T]
348352
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
353+
# Sequence[T]
354+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
349355
):
350356
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
351357
# intended as an iterable, so we don't transform it.

src/parallel/resources/beta/beta.py

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

33
from __future__ import annotations
44

5-
from typing import List, Optional
5+
from typing import Optional
66
from typing_extensions import Literal
77

88
import httpx
99

10-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1111
from ..._utils import maybe_transform, async_maybe_transform
1212
from .task_run import (
1313
TaskRunResource,
@@ -76,7 +76,7 @@ def search(
7676
max_results: Optional[int] | NotGiven = NOT_GIVEN,
7777
objective: Optional[str] | NotGiven = NOT_GIVEN,
7878
processor: Literal["base", "pro"] | NotGiven = NOT_GIVEN,
79-
search_queries: Optional[List[str]] | NotGiven = NOT_GIVEN,
79+
search_queries: Optional[SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
8080
source_policy: Optional[SourcePolicy] | NotGiven = NOT_GIVEN,
8181
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
8282
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -172,7 +172,7 @@ async def search(
172172
max_results: Optional[int] | NotGiven = NOT_GIVEN,
173173
objective: Optional[str] | NotGiven = NOT_GIVEN,
174174
processor: Literal["base", "pro"] | NotGiven = NOT_GIVEN,
175-
search_queries: Optional[List[str]] | NotGiven = NOT_GIVEN,
175+
search_queries: Optional[SequenceNotStr[str]] | NotGiven = NOT_GIVEN,
176176
source_policy: Optional[SourcePolicy] | NotGiven = NOT_GIVEN,
177177
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
178178
# The extra values given here take precedence over values defined on the client or passed to this method.

src/parallel/types/beta/beta_search_params.py

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

33
from __future__ import annotations
44

5-
from typing import List, Optional
5+
from typing import Optional
66
from typing_extensions import Literal, TypedDict
77

8+
from ..._types import SequenceNotStr
89
from ..shared_params.source_policy import SourcePolicy
910

1011
__all__ = ["BetaSearchParams"]
@@ -33,7 +34,7 @@ class BetaSearchParams(TypedDict, total=False):
3334
processor: Literal["base", "pro"]
3435
"""Search processor."""
3536

36-
search_queries: Optional[List[str]]
37+
search_queries: Optional[SequenceNotStr[str]]
3738
"""Optional list of traditional keyword search queries to guide the search.
3839
3940
May contain search operators. At least one of objective or search_queries must

src/parallel/types/beta/mcp_server_param.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, List, Optional
5+
from typing import Dict, Optional
66
from typing_extensions import Literal, Required, TypedDict
77

8+
from ..._types import SequenceNotStr
9+
810
__all__ = ["McpServerParam"]
911

1012

@@ -15,7 +17,7 @@ class McpServerParam(TypedDict, total=False):
1517
url: Required[str]
1618
"""URL of the MCP server."""
1719

18-
allowed_tools: Optional[List[str]]
20+
allowed_tools: Optional[SequenceNotStr[str]]
1921
"""List of allowed tools for the MCP server."""
2022

2123
headers: Optional[Dict[str, str]]

src/parallel/types/shared_params/source_policy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
from __future__ import annotations
44

5-
from typing import List
65
from typing_extensions import TypedDict
76

7+
from ..._types import SequenceNotStr
8+
89
__all__ = ["SourcePolicy"]
910

1011

1112
class SourcePolicy(TypedDict, total=False):
12-
exclude_domains: List[str]
13+
exclude_domains: SequenceNotStr[str]
1314
"""List of domains to exclude from results.
1415
1516
If specified, sources from these domains will be excluded.
1617
"""
1718

18-
include_domains: List[str]
19+
include_domains: SequenceNotStr[str]
1920
"""List of domains to restrict the results to.
2021
2122
If specified, only sources from these domains will be included.

0 commit comments

Comments
 (0)