Skip to content

Commit 35f1e21

Browse files
feat(types): replace List[str] with SequenceNotStr in params
1 parent 79f22e5 commit 35f1e21

16 files changed

+69
-58
lines changed

src/imagekit/_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/imagekit/resources/accounts/url_endpoints.py

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

33
from __future__ import annotations
44

5-
from typing import List
6-
75
import httpx
86

9-
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven
7+
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, SequenceNotStr
108
from ..._utils import maybe_transform, async_maybe_transform
119
from ..._compat import cached_property
1210
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -48,7 +46,7 @@ def create(
4846
self,
4947
*,
5048
description: str,
51-
origins: List[str] | NotGiven = NOT_GIVEN,
49+
origins: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
5250
url_prefix: str | NotGiven = NOT_GIVEN,
5351
url_rewriter: url_endpoint_create_params.URLRewriter | NotGiven = NOT_GIVEN,
5452
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -105,7 +103,7 @@ def update(
105103
id: str,
106104
*,
107105
description: str,
108-
origins: List[str] | NotGiven = NOT_GIVEN,
106+
origins: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
109107
url_prefix: str | NotGiven = NOT_GIVEN,
110108
url_rewriter: url_endpoint_update_params.URLRewriter | NotGiven = NOT_GIVEN,
111109
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -292,7 +290,7 @@ async def create(
292290
self,
293291
*,
294292
description: str,
295-
origins: List[str] | NotGiven = NOT_GIVEN,
293+
origins: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
296294
url_prefix: str | NotGiven = NOT_GIVEN,
297295
url_rewriter: url_endpoint_create_params.URLRewriter | NotGiven = NOT_GIVEN,
298296
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -349,7 +347,7 @@ async def update(
349347
id: str,
350348
*,
351349
description: str,
352-
origins: List[str] | NotGiven = NOT_GIVEN,
350+
origins: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
353351
url_prefix: str | NotGiven = NOT_GIVEN,
354352
url_rewriter: url_endpoint_update_params.URLRewriter | NotGiven = NOT_GIVEN,
355353
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.

src/imagekit/resources/beta/v2/files.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import httpx
99

10-
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
10+
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes, SequenceNotStr
1111
from ...._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
1212
from ...._compat import cached_property
1313
from ...._resource import SyncAPIResource, AsyncAPIResource
@@ -74,7 +74,7 @@ def upload(
7474
]
7575
]
7676
| NotGiven = NOT_GIVEN,
77-
tags: List[str] | NotGiven = NOT_GIVEN,
77+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
7878
transformation: file_upload_params.Transformation | NotGiven = NOT_GIVEN,
7979
use_unique_file_name: bool | NotGiven = NOT_GIVEN,
8080
webhook_url: str | NotGiven = NOT_GIVEN,
@@ -326,7 +326,7 @@ async def upload(
326326
]
327327
]
328328
| NotGiven = NOT_GIVEN,
329-
tags: List[str] | NotGiven = NOT_GIVEN,
329+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
330330
transformation: file_upload_params.Transformation | NotGiven = NOT_GIVEN,
331331
use_unique_file_name: bool | NotGiven = NOT_GIVEN,
332332
webhook_url: str | NotGiven = NOT_GIVEN,

src/imagekit/resources/files/bulk.py

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

33
from __future__ import annotations
44

5-
from typing import List
6-
75
import httpx
86

9-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
7+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
108
from ..._utils import maybe_transform, async_maybe_transform
119
from ..._compat import cached_property
1210
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -49,7 +47,7 @@ def with_streaming_response(self) -> BulkResourceWithStreamingResponse:
4947
def delete(
5048
self,
5149
*,
52-
file_ids: List[str],
50+
file_ids: SequenceNotStr[str],
5351
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5452
# The extra values given here take precedence over values defined on the client or passed to this method.
5553
extra_headers: Headers | None = None,
@@ -89,8 +87,8 @@ def delete(
8987
def add_tags(
9088
self,
9189
*,
92-
file_ids: List[str],
93-
tags: List[str],
90+
file_ids: SequenceNotStr[str],
91+
tags: SequenceNotStr[str],
9492
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
9593
# The extra values given here take precedence over values defined on the client or passed to this method.
9694
extra_headers: Headers | None = None,
@@ -134,8 +132,8 @@ def add_tags(
134132
def remove_ai_tags(
135133
self,
136134
*,
137-
ai_tags: List[str],
138-
file_ids: List[str],
135+
ai_tags: SequenceNotStr[str],
136+
file_ids: SequenceNotStr[str],
139137
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
140138
# The extra values given here take precedence over values defined on the client or passed to this method.
141139
extra_headers: Headers | None = None,
@@ -179,8 +177,8 @@ def remove_ai_tags(
179177
def remove_tags(
180178
self,
181179
*,
182-
file_ids: List[str],
183-
tags: List[str],
180+
file_ids: SequenceNotStr[str],
181+
tags: SequenceNotStr[str],
184182
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
185183
# The extra values given here take precedence over values defined on the client or passed to this method.
186184
extra_headers: Headers | None = None,
@@ -245,7 +243,7 @@ def with_streaming_response(self) -> AsyncBulkResourceWithStreamingResponse:
245243
async def delete(
246244
self,
247245
*,
248-
file_ids: List[str],
246+
file_ids: SequenceNotStr[str],
249247
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
250248
# The extra values given here take precedence over values defined on the client or passed to this method.
251249
extra_headers: Headers | None = None,
@@ -285,8 +283,8 @@ async def delete(
285283
async def add_tags(
286284
self,
287285
*,
288-
file_ids: List[str],
289-
tags: List[str],
286+
file_ids: SequenceNotStr[str],
287+
tags: SequenceNotStr[str],
290288
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
291289
# The extra values given here take precedence over values defined on the client or passed to this method.
292290
extra_headers: Headers | None = None,
@@ -330,8 +328,8 @@ async def add_tags(
330328
async def remove_ai_tags(
331329
self,
332330
*,
333-
ai_tags: List[str],
334-
file_ids: List[str],
331+
ai_tags: SequenceNotStr[str],
332+
file_ids: SequenceNotStr[str],
335333
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
336334
# The extra values given here take precedence over values defined on the client or passed to this method.
337335
extra_headers: Headers | None = None,
@@ -375,8 +373,8 @@ async def remove_ai_tags(
375373
async def remove_tags(
376374
self,
377375
*,
378-
file_ids: List[str],
379-
tags: List[str],
376+
file_ids: SequenceNotStr[str],
377+
tags: SequenceNotStr[str],
380378
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
381379
# The extra values given here take precedence over values defined on the client or passed to this method.
382380
extra_headers: Headers | None = None,

src/imagekit/resources/files/files.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
AsyncBulkResourceWithStreamingResponse,
1717
)
1818
from ...types import file_copy_params, file_move_params, file_rename_params, file_update_params, file_upload_params
19-
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, FileTypes
19+
from ..._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, FileTypes, SequenceNotStr
2020
from ..._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
2121
from .metadata import (
2222
MetadataResource,
@@ -398,7 +398,7 @@ def upload(
398398
]
399399
| NotGiven = NOT_GIVEN,
400400
signature: str | NotGiven = NOT_GIVEN,
401-
tags: List[str] | NotGiven = NOT_GIVEN,
401+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
402402
transformation: file_upload_params.Transformation | NotGiven = NOT_GIVEN,
403403
use_unique_file_name: bool | NotGiven = NOT_GIVEN,
404404
webhook_url: str | NotGiven = NOT_GIVEN,
@@ -969,7 +969,7 @@ async def upload(
969969
]
970970
| NotGiven = NOT_GIVEN,
971971
signature: str | NotGiven = NOT_GIVEN,
972-
tags: List[str] | NotGiven = NOT_GIVEN,
972+
tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
973973
transformation: file_upload_params.Transformation | NotGiven = NOT_GIVEN,
974974
use_unique_file_name: bool | NotGiven = NOT_GIVEN,
975975
webhook_url: str | NotGiven = NOT_GIVEN,

src/imagekit/types/accounts/url_endpoint_create_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, Union
5+
from typing import Union
66
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
77

8+
from ..._types import SequenceNotStr
89
from ..._utils import PropertyInfo
910

1011
__all__ = ["URLEndpointCreateParams", "URLRewriter", "URLRewriterCloudinary", "URLRewriterImgix", "URLRewriterAkamai"]
@@ -14,7 +15,7 @@ class URLEndpointCreateParams(TypedDict, total=False):
1415
description: Required[str]
1516
"""Description of the URL endpoint."""
1617

17-
origins: List[str]
18+
origins: SequenceNotStr[str]
1819
"""
1920
Ordered list of origin IDs to try when the file isn’t in the Media Library;
2021
ImageKit checks them in the sequence provided. Origin must be created before it

src/imagekit/types/accounts/url_endpoint_update_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, Union
5+
from typing import Union
66
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
77

8+
from ..._types import SequenceNotStr
89
from ..._utils import PropertyInfo
910

1011
__all__ = ["URLEndpointUpdateParams", "URLRewriter", "URLRewriterCloudinary", "URLRewriterImgix", "URLRewriterAkamai"]
@@ -14,7 +15,7 @@ class URLEndpointUpdateParams(TypedDict, total=False):
1415
description: Required[str]
1516
"""Description of the URL endpoint."""
1617

17-
origins: List[str]
18+
origins: SequenceNotStr[str]
1819
"""
1920
Ordered list of origin IDs to try when the file isn’t in the Media Library;
2021
ImageKit checks them in the sequence provided. Origin must be created before it

src/imagekit/types/beta/v2/file_upload_params.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Dict, List, Union, Iterable
66
from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
77

8-
from ...._types import FileTypes
8+
from ...._types import FileTypes, SequenceNotStr
99
from ...._utils import PropertyInfo
1010

1111
__all__ = [
@@ -157,7 +157,7 @@ class FileUploadParams(TypedDict, total=False):
157157
]
158158
"""Array of response field keys to include in the API response body."""
159159

160-
tags: List[str]
160+
tags: SequenceNotStr[str]
161161
"""Set the tags while uploading the file. Provide an array of tag strings (e.g.
162162
163163
`["tag1", "tag2", "tag3"]`). The combined length of all tag characters must not

src/imagekit/types/custom_metadata_field_create_params.py

Lines changed: 6 additions & 3 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, Union
5+
from typing import Union
66
from typing_extensions import Literal, Required, Annotated, TypedDict
77

8+
from .._types import SequenceNotStr
89
from .._utils import PropertyInfo
910

1011
__all__ = ["CustomMetadataFieldCreateParams", "Schema"]
@@ -32,7 +33,9 @@ class Schema(TypedDict, total=False):
3233
type: Required[Literal["Text", "Textarea", "Number", "Date", "Boolean", "SingleSelect", "MultiSelect"]]
3334
"""Type of the custom metadata field."""
3435

35-
default_value: Annotated[Union[str, float, bool, List[Union[str, float, bool]]], PropertyInfo(alias="defaultValue")]
36+
default_value: Annotated[
37+
Union[str, float, bool, SequenceNotStr[Union[str, float, bool]]], PropertyInfo(alias="defaultValue")
38+
]
3639
"""The default value for this custom metadata field.
3740
3841
This property is only required if `isValueRequired` property is set to `true`.
@@ -74,7 +77,7 @@ class Schema(TypedDict, total=False):
7477
set the minimum numeric value.
7578
"""
7679

77-
select_options: Annotated[List[Union[str, float, bool]], PropertyInfo(alias="selectOptions")]
80+
select_options: Annotated[SequenceNotStr[Union[str, float, bool]], PropertyInfo(alias="selectOptions")]
7881
"""An array of allowed values.
7982
8083
This property is only required if `type` property is set to `SingleSelect` or

src/imagekit/types/custom_metadata_field_update_params.py

Lines changed: 6 additions & 3 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, Union
5+
from typing import Union
66
from typing_extensions import Annotated, TypedDict
77

8+
from .._types import SequenceNotStr
89
from .._utils import PropertyInfo
910

1011
__all__ = ["CustomMetadataFieldUpdateParams", "Schema"]
@@ -30,7 +31,9 @@ class CustomMetadataFieldUpdateParams(TypedDict, total=False):
3031

3132

3233
class Schema(TypedDict, total=False):
33-
default_value: Annotated[Union[str, float, bool, List[Union[str, float, bool]]], PropertyInfo(alias="defaultValue")]
34+
default_value: Annotated[
35+
Union[str, float, bool, SequenceNotStr[Union[str, float, bool]]], PropertyInfo(alias="defaultValue")
36+
]
3437
"""The default value for this custom metadata field.
3538
3639
This property is only required if `isValueRequired` property is set to `true`.
@@ -72,7 +75,7 @@ class Schema(TypedDict, total=False):
7275
set the minimum numeric value.
7376
"""
7477

75-
select_options: Annotated[List[Union[str, float, bool]], PropertyInfo(alias="selectOptions")]
78+
select_options: Annotated[SequenceNotStr[Union[str, float, bool]], PropertyInfo(alias="selectOptions")]
7679
"""An array of allowed values.
7780
7881
This property is only required if `type` property is set to `SingleSelect` or

0 commit comments

Comments
 (0)