Skip to content

Commit e19113c

Browse files
feat(types): replace List[str] with SequenceNotStr in params
1 parent 2032a76 commit e19113c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+182
-148
lines changed

src/knockapi/_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/knockapi/resources/channels/bulk.py

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

33
from __future__ import annotations
44

5-
from typing import List, Union
5+
from typing import Union
66
from datetime import datetime
77
from typing_extensions import Literal
88

99
import httpx
1010

11-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
11+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1212
from ..._utils import maybe_transform, async_maybe_transform
1313
from ..._compat import cached_property
1414
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -64,10 +64,10 @@ def update_message_status(
6464
has_tenant: bool | NotGiven = NOT_GIVEN,
6565
newer_than: Union[str, datetime] | NotGiven = NOT_GIVEN,
6666
older_than: Union[str, datetime] | NotGiven = NOT_GIVEN,
67-
recipient_ids: List[str] | NotGiven = NOT_GIVEN,
68-
tenants: List[str] | NotGiven = NOT_GIVEN,
67+
recipient_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
68+
tenants: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
6969
trigger_data: str | NotGiven = NOT_GIVEN,
70-
workflows: List[str] | NotGiven = NOT_GIVEN,
70+
workflows: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
7171
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
7272
# The extra values given here take precedence over values defined on the client or passed to this method.
7373
extra_headers: Headers | None = None,
@@ -180,10 +180,10 @@ async def update_message_status(
180180
has_tenant: bool | NotGiven = NOT_GIVEN,
181181
newer_than: Union[str, datetime] | NotGiven = NOT_GIVEN,
182182
older_than: Union[str, datetime] | NotGiven = NOT_GIVEN,
183-
recipient_ids: List[str] | NotGiven = NOT_GIVEN,
184-
tenants: List[str] | NotGiven = NOT_GIVEN,
183+
recipient_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
184+
tenants: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
185185
trigger_data: str | NotGiven = NOT_GIVEN,
186-
workflows: List[str] | NotGiven = NOT_GIVEN,
186+
workflows: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
187187
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
188188
# The extra values given here take precedence over values defined on the client or passed to this method.
189189
extra_headers: Headers | None = None,

src/knockapi/resources/messages/batch.py

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

33
from __future__ import annotations
44

5-
from typing import Dict, List, Optional
5+
from typing import Dict, Optional
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
@@ -62,7 +62,7 @@ def with_streaming_response(self) -> BatchResourceWithStreamingResponse:
6262
def archive(
6363
self,
6464
*,
65-
message_ids: List[str],
65+
message_ids: SequenceNotStr[str],
6666
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6767
# The extra values given here take precedence over values defined on the client or passed to this method.
6868
extra_headers: Headers | None = None,
@@ -98,7 +98,7 @@ def archive(
9898
def get_content(
9999
self,
100100
*,
101-
message_ids: List[str],
101+
message_ids: SequenceNotStr[str],
102102
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
103103
# The extra values given here take precedence over values defined on the client or passed to this method.
104104
extra_headers: Headers | None = None,
@@ -135,7 +135,7 @@ def get_content(
135135
def mark_as_interacted(
136136
self,
137137
*,
138-
message_ids: List[str],
138+
message_ids: SequenceNotStr[str],
139139
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
140140
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
141141
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -183,7 +183,7 @@ def mark_as_interacted(
183183
def mark_as_read(
184184
self,
185185
*,
186-
message_ids: List[str],
186+
message_ids: SequenceNotStr[str],
187187
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
188188
# The extra values given here take precedence over values defined on the client or passed to this method.
189189
extra_headers: Headers | None = None,
@@ -219,7 +219,7 @@ def mark_as_read(
219219
def mark_as_seen(
220220
self,
221221
*,
222-
message_ids: List[str],
222+
message_ids: SequenceNotStr[str],
223223
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
224224
# The extra values given here take precedence over values defined on the client or passed to this method.
225225
extra_headers: Headers | None = None,
@@ -256,7 +256,7 @@ def mark_as_seen(
256256
def mark_as_unread(
257257
self,
258258
*,
259-
message_ids: List[str],
259+
message_ids: SequenceNotStr[str],
260260
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
261261
# The extra values given here take precedence over values defined on the client or passed to this method.
262262
extra_headers: Headers | None = None,
@@ -293,7 +293,7 @@ def mark_as_unread(
293293
def mark_as_unseen(
294294
self,
295295
*,
296-
message_ids: List[str],
296+
message_ids: SequenceNotStr[str],
297297
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
298298
# The extra values given here take precedence over values defined on the client or passed to this method.
299299
extra_headers: Headers | None = None,
@@ -330,7 +330,7 @@ def mark_as_unseen(
330330
def unarchive(
331331
self,
332332
*,
333-
message_ids: List[str],
333+
message_ids: SequenceNotStr[str],
334334
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
335335
# The extra values given here take precedence over values defined on the client or passed to this method.
336336
extra_headers: Headers | None = None,
@@ -388,7 +388,7 @@ def with_streaming_response(self) -> AsyncBatchResourceWithStreamingResponse:
388388
async def archive(
389389
self,
390390
*,
391-
message_ids: List[str],
391+
message_ids: SequenceNotStr[str],
392392
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
393393
# The extra values given here take precedence over values defined on the client or passed to this method.
394394
extra_headers: Headers | None = None,
@@ -424,7 +424,7 @@ async def archive(
424424
async def get_content(
425425
self,
426426
*,
427-
message_ids: List[str],
427+
message_ids: SequenceNotStr[str],
428428
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
429429
# The extra values given here take precedence over values defined on the client or passed to this method.
430430
extra_headers: Headers | None = None,
@@ -463,7 +463,7 @@ async def get_content(
463463
async def mark_as_interacted(
464464
self,
465465
*,
466-
message_ids: List[str],
466+
message_ids: SequenceNotStr[str],
467467
metadata: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN,
468468
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
469469
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -511,7 +511,7 @@ async def mark_as_interacted(
511511
async def mark_as_read(
512512
self,
513513
*,
514-
message_ids: List[str],
514+
message_ids: SequenceNotStr[str],
515515
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
516516
# The extra values given here take precedence over values defined on the client or passed to this method.
517517
extra_headers: Headers | None = None,
@@ -549,7 +549,7 @@ async def mark_as_read(
549549
async def mark_as_seen(
550550
self,
551551
*,
552-
message_ids: List[str],
552+
message_ids: SequenceNotStr[str],
553553
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
554554
# The extra values given here take precedence over values defined on the client or passed to this method.
555555
extra_headers: Headers | None = None,
@@ -588,7 +588,7 @@ async def mark_as_seen(
588588
async def mark_as_unread(
589589
self,
590590
*,
591-
message_ids: List[str],
591+
message_ids: SequenceNotStr[str],
592592
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
593593
# The extra values given here take precedence over values defined on the client or passed to this method.
594594
extra_headers: Headers | None = None,
@@ -627,7 +627,7 @@ async def mark_as_unread(
627627
async def mark_as_unseen(
628628
self,
629629
*,
630-
message_ids: List[str],
630+
message_ids: SequenceNotStr[str],
631631
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
632632
# The extra values given here take precedence over values defined on the client or passed to this method.
633633
extra_headers: Headers | None = None,
@@ -666,7 +666,7 @@ async def mark_as_unseen(
666666
async def unarchive(
667667
self,
668668
*,
669-
message_ids: List[str],
669+
message_ids: SequenceNotStr[str],
670670
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
671671
# The extra values given here take precedence over values defined on the client or passed to this method.
672672
extra_headers: Headers | None = None,

src/knockapi/resources/messages/messages.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
message_list_delivery_logs_params,
2323
message_mark_as_interacted_params,
2424
)
25-
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
25+
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
2626
from ..._utils import maybe_transform, async_maybe_transform
2727
from ..._compat import cached_property
2828
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -78,14 +78,14 @@ def list(
7878
]
7979
| NotGiven = NOT_GIVEN,
8080
inserted_at: message_list_params.InsertedAt | NotGiven = NOT_GIVEN,
81-
message_ids: List[str] | NotGiven = NOT_GIVEN,
81+
message_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
8282
page_size: int | NotGiven = NOT_GIVEN,
8383
source: str | NotGiven = NOT_GIVEN,
8484
status: List[Literal["queued", "sent", "delivered", "delivery_attempted", "undelivered", "not_sent", "bounced"]]
8585
| NotGiven = NOT_GIVEN,
8686
tenant: str | NotGiven = NOT_GIVEN,
8787
trigger_data: str | NotGiven = NOT_GIVEN,
88-
workflow_categories: List[str] | NotGiven = NOT_GIVEN,
88+
workflow_categories: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
8989
workflow_recipient_run_id: str | NotGiven = NOT_GIVEN,
9090
workflow_run_id: str | NotGiven = NOT_GIVEN,
9191
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -694,14 +694,14 @@ def list(
694694
]
695695
| NotGiven = NOT_GIVEN,
696696
inserted_at: message_list_params.InsertedAt | NotGiven = NOT_GIVEN,
697-
message_ids: List[str] | NotGiven = NOT_GIVEN,
697+
message_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
698698
page_size: int | NotGiven = NOT_GIVEN,
699699
source: str | NotGiven = NOT_GIVEN,
700700
status: List[Literal["queued", "sent", "delivered", "delivery_attempted", "undelivered", "not_sent", "bounced"]]
701701
| NotGiven = NOT_GIVEN,
702702
tenant: str | NotGiven = NOT_GIVEN,
703703
trigger_data: str | NotGiven = NOT_GIVEN,
704-
workflow_categories: List[str] | NotGiven = NOT_GIVEN,
704+
workflow_categories: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
705705
workflow_recipient_run_id: str | NotGiven = NOT_GIVEN,
706706
workflow_run_id: str | NotGiven = NOT_GIVEN,
707707
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.

src/knockapi/resources/objects/bulk.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
@@ -47,7 +47,7 @@ def delete(
4747
self,
4848
collection: str,
4949
*,
50-
object_ids: List[str],
50+
object_ids: SequenceNotStr[str],
5151
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5252
# The extra values given here take precedence over values defined on the client or passed to this method.
5353
extra_headers: Headers | None = None,
@@ -186,7 +186,7 @@ async def delete(
186186
self,
187187
collection: str,
188188
*,
189-
object_ids: List[str],
189+
object_ids: SequenceNotStr[str],
190190
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
191191
# The extra values given here take precedence over values defined on the client or passed to this method.
192192
extra_headers: Headers | None = None,

0 commit comments

Comments
 (0)