Skip to content

Commit 688059b

Browse files
feat(types): replace List[str] with SequenceNotStr in params
1 parent e833554 commit 688059b

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/kernel/_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/kernel/resources/browsers/process.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
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
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 ..._compat import cached_property
1313
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -55,7 +55,7 @@ def exec(
5555
id: str,
5656
*,
5757
command: str,
58-
args: List[str] | NotGiven = NOT_GIVEN,
58+
args: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
5959
as_root: bool | NotGiven = NOT_GIVEN,
6060
as_user: Optional[str] | NotGiven = NOT_GIVEN,
6161
cwd: Optional[str] | NotGiven = NOT_GIVEN,
@@ -161,7 +161,7 @@ def spawn(
161161
id: str,
162162
*,
163163
command: str,
164-
args: List[str] | NotGiven = NOT_GIVEN,
164+
args: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
165165
as_root: bool | NotGiven = NOT_GIVEN,
166166
as_user: Optional[str] | NotGiven = NOT_GIVEN,
167167
cwd: Optional[str] | NotGiven = NOT_GIVEN,
@@ -363,7 +363,7 @@ async def exec(
363363
id: str,
364364
*,
365365
command: str,
366-
args: List[str] | NotGiven = NOT_GIVEN,
366+
args: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
367367
as_root: bool | NotGiven = NOT_GIVEN,
368368
as_user: Optional[str] | NotGiven = NOT_GIVEN,
369369
cwd: Optional[str] | NotGiven = NOT_GIVEN,
@@ -469,7 +469,7 @@ async def spawn(
469469
id: str,
470470
*,
471471
command: str,
472-
args: List[str] | NotGiven = NOT_GIVEN,
472+
args: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
473473
as_root: bool | NotGiven = NOT_GIVEN,
474474
as_user: Optional[str] | NotGiven = NOT_GIVEN,
475475
cwd: Optional[str] | NotGiven = NOT_GIVEN,

src/kernel/types/browsers/process_exec_params.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
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 Required, TypedDict
77

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

1012

1113
class ProcessExecParams(TypedDict, total=False):
1214
command: Required[str]
1315
"""Executable or shell command to run."""
1416

15-
args: List[str]
17+
args: SequenceNotStr[str]
1618
"""Command arguments."""
1719

1820
as_root: bool

src/kernel/types/browsers/process_spawn_params.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
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 Required, TypedDict
77

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

1012

1113
class ProcessSpawnParams(TypedDict, total=False):
1214
command: Required[str]
1315
"""Executable or shell command to run."""
1416

15-
args: List[str]
17+
args: SequenceNotStr[str]
1618
"""Command arguments."""
1719

1820
as_root: bool

0 commit comments

Comments
 (0)