Skip to content

Commit ac97bcc

Browse files
feat(types): replace List[str] with SequenceNotStr in params
1 parent 59172cd commit ac97bcc

22 files changed

+93
-77
lines changed

src/nextbillionai/_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/nextbillionai/resources/geofence/batch.py

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

33
from __future__ import annotations
44

5-
from typing import List, Iterable
5+
from typing import Iterable
66

77
import httpx
88

9-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1010
from ..._utils import maybe_transform, async_maybe_transform
1111
from ..._compat import cached_property
1212
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -140,7 +140,7 @@ def delete(
140140
self,
141141
*,
142142
key: str,
143-
ids: List[str] | NotGiven = NOT_GIVEN,
143+
ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
144144
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
145145
# The extra values given here take precedence over values defined on the client or passed to this method.
146146
extra_headers: Headers | None = None,
@@ -294,7 +294,7 @@ async def delete(
294294
self,
295295
*,
296296
key: str,
297-
ids: List[str] | NotGiven = NOT_GIVEN,
297+
ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
298298
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
299299
# The extra values given here take precedence over values defined on the client or passed to this method.
300300
extra_headers: Headers | None = None,

src/nextbillionai/resources/geofence/console.py

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

33
from __future__ import annotations
44

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

87
import httpx
98

10-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1110
from ..._utils import maybe_transform, async_maybe_transform
1211
from ..._compat import cached_property
1312
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -55,7 +54,7 @@ def preview(
5554
meta_data: object | NotGiven = NOT_GIVEN,
5655
name: str | NotGiven = NOT_GIVEN,
5756
polygon: console_preview_params.Polygon | NotGiven = NOT_GIVEN,
58-
tags: List[str] | NotGiven = NOT_GIVEN,
57+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
5958
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6059
# The extra values given here take precedence over values defined on the client or passed to this method.
6160
extra_headers: Headers | None = None,
@@ -206,7 +205,7 @@ async def preview(
206205
meta_data: object | NotGiven = NOT_GIVEN,
207206
name: str | NotGiven = NOT_GIVEN,
208207
polygon: console_preview_params.Polygon | NotGiven = NOT_GIVEN,
209-
tags: List[str] | NotGiven = NOT_GIVEN,
208+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
210209
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
211210
# The extra values given here take precedence over values defined on the client or passed to this method.
212211
extra_headers: Headers | None = None,

src/nextbillionai/resources/geofence/geofence.py

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

33
from __future__ import annotations
44

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

87
import httpx
@@ -31,7 +30,7 @@
3130
ConsoleResourceWithStreamingResponse,
3231
AsyncConsoleResourceWithStreamingResponse,
3332
)
34-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
33+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
3534
from ..._utils import maybe_transform, async_maybe_transform
3635
from ..._compat import cached_property
3736
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -90,7 +89,7 @@ def create(
9089
meta_data: object | NotGiven = NOT_GIVEN,
9190
name: str | NotGiven = NOT_GIVEN,
9291
polygon: geofence_create_params.Polygon | NotGiven = NOT_GIVEN,
93-
tags: List[str] | NotGiven = NOT_GIVEN,
92+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
9493
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
9594
# The extra values given here take precedence over values defined on the client or passed to this method.
9695
extra_headers: Headers | None = None,
@@ -231,7 +230,7 @@ def update(
231230
meta_data: object | NotGiven = NOT_GIVEN,
232231
name: str | NotGiven = NOT_GIVEN,
233232
polygon: geofence_update_params.Polygon | NotGiven = NOT_GIVEN,
234-
tags: List[str] | NotGiven = NOT_GIVEN,
233+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
235234
type: Literal["circle", "polygon", "isochrone"] | NotGiven = NOT_GIVEN,
236235
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
237236
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -525,7 +524,7 @@ async def create(
525524
meta_data: object | NotGiven = NOT_GIVEN,
526525
name: str | NotGiven = NOT_GIVEN,
527526
polygon: geofence_create_params.Polygon | NotGiven = NOT_GIVEN,
528-
tags: List[str] | NotGiven = NOT_GIVEN,
527+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
529528
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
530529
# The extra values given here take precedence over values defined on the client or passed to this method.
531530
extra_headers: Headers | None = None,
@@ -666,7 +665,7 @@ async def update(
666665
meta_data: object | NotGiven = NOT_GIVEN,
667666
name: str | NotGiven = NOT_GIVEN,
668667
polygon: geofence_update_params.Polygon | NotGiven = NOT_GIVEN,
669-
tags: List[str] | NotGiven = NOT_GIVEN,
668+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
670669
type: Literal["circle", "polygon", "isochrone"] | NotGiven = NOT_GIVEN,
671670
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
672671
# The extra values given here take precedence over values defined on the client or passed to this method.

src/nextbillionai/resources/optimization/optimization.py

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

33
from __future__ import annotations
44

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

87
import httpx
@@ -16,7 +15,7 @@
1615
AsyncV2ResourceWithStreamingResponse,
1716
)
1817
from ...types import optimization_compute_params, optimization_re_optimize_params
19-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
18+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
2019
from ..._utils import maybe_transform, async_maybe_transform
2120
from ..._compat import cached_property
2221
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -194,7 +193,7 @@ def re_optimize(
194193
key: str,
195194
existing_request_id: str,
196195
job_changes: optimization_re_optimize_params.JobChanges | NotGiven = NOT_GIVEN,
197-
locations: List[str] | NotGiven = NOT_GIVEN,
196+
locations: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
198197
shipment_changes: optimization_re_optimize_params.ShipmentChanges | NotGiven = NOT_GIVEN,
199198
vehicle_changes: optimization_re_optimize_params.VehicleChanges | NotGiven = NOT_GIVEN,
200199
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -433,7 +432,7 @@ async def re_optimize(
433432
key: str,
434433
existing_request_id: str,
435434
job_changes: optimization_re_optimize_params.JobChanges | NotGiven = NOT_GIVEN,
436-
locations: List[str] | NotGiven = NOT_GIVEN,
435+
locations: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
437436
shipment_changes: optimization_re_optimize_params.ShipmentChanges | NotGiven = NOT_GIVEN,
438437
vehicle_changes: optimization_re_optimize_params.VehicleChanges | NotGiven = NOT_GIVEN,
439438
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.

src/nextbillionai/resources/skynet/asset/asset.py

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

33
from __future__ import annotations
44

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

87
import httpx
@@ -23,7 +22,7 @@
2322
LocationResourceWithStreamingResponse,
2423
AsyncLocationResourceWithStreamingResponse,
2524
)
26-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
25+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
2726
from ...._utils import maybe_transform, async_maybe_transform
2827
from ...._compat import cached_property
2928
from ...._resource import SyncAPIResource, AsyncAPIResource
@@ -91,7 +90,7 @@ def create(
9190
description: str | NotGiven = NOT_GIVEN,
9291
meta_data: MetaDataParam | NotGiven = NOT_GIVEN,
9392
name: str | NotGiven = NOT_GIVEN,
94-
tags: List[str] | NotGiven = NOT_GIVEN,
93+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
9594
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
9695
# The extra values given here take precedence over values defined on the client or passed to this method.
9796
extra_headers: Headers | None = None,
@@ -238,7 +237,7 @@ def update(
238237
description: str | NotGiven = NOT_GIVEN,
239238
meta_data: MetaDataParam | NotGiven = NOT_GIVEN,
240239
name: str | NotGiven = NOT_GIVEN,
241-
tags: List[str] | NotGiven = NOT_GIVEN,
240+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
242241
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
243242
# The extra values given here take precedence over values defined on the client or passed to this method.
244243
extra_headers: Headers | None = None,
@@ -681,7 +680,7 @@ async def create(
681680
description: str | NotGiven = NOT_GIVEN,
682681
meta_data: MetaDataParam | NotGiven = NOT_GIVEN,
683682
name: str | NotGiven = NOT_GIVEN,
684-
tags: List[str] | NotGiven = NOT_GIVEN,
683+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
685684
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
686685
# The extra values given here take precedence over values defined on the client or passed to this method.
687686
extra_headers: Headers | None = None,
@@ -828,7 +827,7 @@ async def update(
828827
description: str | NotGiven = NOT_GIVEN,
829828
meta_data: MetaDataParam | NotGiven = NOT_GIVEN,
830829
name: str | NotGiven = NOT_GIVEN,
831-
tags: List[str] | NotGiven = NOT_GIVEN,
830+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
832831
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
833832
# The extra values given here take precedence over values defined on the client or passed to this method.
834833
extra_headers: Headers | None = None,

src/nextbillionai/resources/skynet/config.py

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

33
from __future__ import annotations
44

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

87
import httpx
98

10-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1110
from ..._utils import maybe_transform, async_maybe_transform
1211
from ..._compat import cached_property
1312
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -98,7 +97,7 @@ def update(
9897
*,
9998
key: str,
10099
cluster: Literal["america"] | NotGiven = NOT_GIVEN,
101-
webhook: List[str] | NotGiven = NOT_GIVEN,
100+
webhook: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
102101
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
103102
# The extra values given here take precedence over values defined on the client or passed to this method.
104103
extra_headers: Headers | None = None,
@@ -256,7 +255,7 @@ async def update(
256255
*,
257256
key: str,
258257
cluster: Literal["america"] | NotGiven = NOT_GIVEN,
259-
webhook: List[str] | NotGiven = NOT_GIVEN,
258+
webhook: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
260259
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
261260
# The extra values given here take precedence over values defined on the client or passed to this method.
262261
extra_headers: Headers | None = None,

src/nextbillionai/resources/skynet/monitor.py

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

33
from __future__ import annotations
44

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

87
import httpx
98

10-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
9+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1110
from ..._utils import maybe_transform, async_maybe_transform
1211
from ..._compat import cached_property
1312
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -58,13 +57,13 @@ def create(
5857
self,
5958
*,
6059
key: str,
61-
tags: List[str],
60+
tags: SequenceNotStr[str],
6261
type: Literal["enter", "exit", "enter_and_exit", "speeding", "idle"],
6362
cluster: Literal["america"] | NotGiven = NOT_GIVEN,
6463
custom_id: str | NotGiven = NOT_GIVEN,
6564
description: str | NotGiven = NOT_GIVEN,
6665
geofence_config: monitor_create_params.GeofenceConfig | NotGiven = NOT_GIVEN,
67-
geofence_ids: List[str] | NotGiven = NOT_GIVEN,
66+
geofence_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
6867
idle_config: monitor_create_params.IdleConfig | NotGiven = NOT_GIVEN,
6968
match_filter: monitor_create_params.MatchFilter | NotGiven = NOT_GIVEN,
7069
meta_data: MetadataParam | NotGiven = NOT_GIVEN,
@@ -255,13 +254,13 @@ def update(
255254
key: str,
256255
description: str | NotGiven = NOT_GIVEN,
257256
geofence_config: monitor_update_params.GeofenceConfig | NotGiven = NOT_GIVEN,
258-
geofence_ids: List[str] | NotGiven = NOT_GIVEN,
257+
geofence_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
259258
idle_config: monitor_update_params.IdleConfig | NotGiven = NOT_GIVEN,
260259
match_filter: monitor_update_params.MatchFilter | NotGiven = NOT_GIVEN,
261260
meta_data: MetadataParam | NotGiven = NOT_GIVEN,
262261
name: str | NotGiven = NOT_GIVEN,
263262
speeding_config: monitor_update_params.SpeedingConfig | NotGiven = NOT_GIVEN,
264-
tags: List[str] | NotGiven = NOT_GIVEN,
263+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
265264
type: Literal["enter", "exit", "enter_and_exit", "speeding", "idle"] | NotGiven = NOT_GIVEN,
266265
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
267266
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -517,13 +516,13 @@ async def create(
517516
self,
518517
*,
519518
key: str,
520-
tags: List[str],
519+
tags: SequenceNotStr[str],
521520
type: Literal["enter", "exit", "enter_and_exit", "speeding", "idle"],
522521
cluster: Literal["america"] | NotGiven = NOT_GIVEN,
523522
custom_id: str | NotGiven = NOT_GIVEN,
524523
description: str | NotGiven = NOT_GIVEN,
525524
geofence_config: monitor_create_params.GeofenceConfig | NotGiven = NOT_GIVEN,
526-
geofence_ids: List[str] | NotGiven = NOT_GIVEN,
525+
geofence_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
527526
idle_config: monitor_create_params.IdleConfig | NotGiven = NOT_GIVEN,
528527
match_filter: monitor_create_params.MatchFilter | NotGiven = NOT_GIVEN,
529528
meta_data: MetadataParam | NotGiven = NOT_GIVEN,
@@ -714,13 +713,13 @@ async def update(
714713
key: str,
715714
description: str | NotGiven = NOT_GIVEN,
716715
geofence_config: monitor_update_params.GeofenceConfig | NotGiven = NOT_GIVEN,
717-
geofence_ids: List[str] | NotGiven = NOT_GIVEN,
716+
geofence_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
718717
idle_config: monitor_update_params.IdleConfig | NotGiven = NOT_GIVEN,
719718
match_filter: monitor_update_params.MatchFilter | NotGiven = NOT_GIVEN,
720719
meta_data: MetadataParam | NotGiven = NOT_GIVEN,
721720
name: str | NotGiven = NOT_GIVEN,
722721
speeding_config: monitor_update_params.SpeedingConfig | NotGiven = NOT_GIVEN,
723-
tags: List[str] | NotGiven = NOT_GIVEN,
722+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
724723
type: Literal["enter", "exit", "enter_and_exit", "speeding", "idle"] | NotGiven = NOT_GIVEN,
725724
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
726725
# The extra values given here take precedence over values defined on the client or passed to this method.

src/nextbillionai/types/geofence/batch_delete_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
65
from typing_extensions import Required, TypedDict
76

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

1011

@@ -15,7 +16,7 @@ class BatchDeleteParams(TypedDict, total=False):
1516
API.
1617
"""
1718

18-
ids: List[str]
19+
ids: SequenceNotStr[str]
1920
"""An array IDs of the geofence to be deleted.
2021
2122
These are the IDs that were generated/provided at the time of creating the

src/nextbillionai/types/geofence/console_preview_params.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 List, Iterable
5+
from typing import Iterable
66
from typing_extensions import Literal, Required, TypedDict
77

8+
from ..._types import SequenceNotStr
9+
810
__all__ = ["ConsolePreviewParams", "Circle", "CircleCenter", "Isochrone", "Polygon", "PolygonGeojson"]
911

1012

@@ -66,7 +68,7 @@ class ConsolePreviewParams(TypedDict, total=False):
6668
Area of the polygon should be less than 2000 km<sup>2</sup>.
6769
"""
6870

69-
tags: List[str]
71+
tags: SequenceNotStr[str]
7072
"""An array of strings to associate multiple tags to the geofence.
7173
7274
tags can be used to search or filter geofences (using Get Geofence List method).

0 commit comments

Comments
 (0)