Skip to content

Commit f4bfda3

Browse files
feat(types): replace List[str] with SequenceNotStr in params
1 parent 8412e4d commit f4bfda3

15 files changed

+65
-53
lines changed

src/supermemory/_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/supermemory/resources/connections.py

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

33
from __future__ import annotations
44

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

88
import httpx
@@ -15,7 +15,7 @@
1515
connection_list_documents_params,
1616
connection_delete_by_provider_params,
1717
)
18-
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
18+
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
1919
from .._utils import maybe_transform, async_maybe_transform
2020
from .._compat import cached_property
2121
from .._resource import SyncAPIResource, AsyncAPIResource
@@ -61,7 +61,7 @@ def create(
6161
self,
6262
provider: Literal["notion", "google-drive", "onedrive"],
6363
*,
64-
container_tags: List[str] | NotGiven = NOT_GIVEN,
64+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
6565
document_limit: int | NotGiven = NOT_GIVEN,
6666
metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
6767
redirect_url: str | NotGiven = NOT_GIVEN,
@@ -106,7 +106,7 @@ def create(
106106
def list(
107107
self,
108108
*,
109-
container_tags: List[str] | NotGiven = NOT_GIVEN,
109+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
110110
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
111111
# The extra values given here take precedence over values defined on the client or passed to this method.
112112
extra_headers: Headers | None = None,
@@ -174,7 +174,7 @@ def delete_by_provider(
174174
self,
175175
provider: Literal["notion", "google-drive", "onedrive"],
176176
*,
177-
container_tags: List[str],
177+
container_tags: SequenceNotStr[str],
178178
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
179179
# The extra values given here take precedence over values defined on the client or passed to this method.
180180
extra_headers: Headers | None = None,
@@ -247,7 +247,7 @@ def get_by_tags(
247247
self,
248248
provider: Literal["notion", "google-drive", "onedrive"],
249249
*,
250-
container_tags: List[str],
250+
container_tags: SequenceNotStr[str],
251251
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
252252
# The extra values given here take precedence over values defined on the client or passed to this method.
253253
extra_headers: Headers | None = None,
@@ -286,7 +286,7 @@ def import_(
286286
self,
287287
provider: Literal["notion", "google-drive", "onedrive"],
288288
*,
289-
container_tags: List[str] | NotGiven = NOT_GIVEN,
289+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
290290
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
291291
# The extra values given here take precedence over values defined on the client or passed to this method.
292292
extra_headers: Headers | None = None,
@@ -324,7 +324,7 @@ def list_documents(
324324
self,
325325
provider: Literal["notion", "google-drive", "onedrive"],
326326
*,
327-
container_tags: List[str] | NotGiven = NOT_GIVEN,
327+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
328328
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
329329
# The extra values given here take precedence over values defined on the client or passed to this method.
330330
extra_headers: Headers | None = None,
@@ -384,7 +384,7 @@ async def create(
384384
self,
385385
provider: Literal["notion", "google-drive", "onedrive"],
386386
*,
387-
container_tags: List[str] | NotGiven = NOT_GIVEN,
387+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
388388
document_limit: int | NotGiven = NOT_GIVEN,
389389
metadata: Optional[Dict[str, Union[str, float, bool]]] | NotGiven = NOT_GIVEN,
390390
redirect_url: str | NotGiven = NOT_GIVEN,
@@ -429,7 +429,7 @@ async def create(
429429
async def list(
430430
self,
431431
*,
432-
container_tags: List[str] | NotGiven = NOT_GIVEN,
432+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
433433
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
434434
# The extra values given here take precedence over values defined on the client or passed to this method.
435435
extra_headers: Headers | None = None,
@@ -499,7 +499,7 @@ async def delete_by_provider(
499499
self,
500500
provider: Literal["notion", "google-drive", "onedrive"],
501501
*,
502-
container_tags: List[str],
502+
container_tags: SequenceNotStr[str],
503503
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
504504
# The extra values given here take precedence over values defined on the client or passed to this method.
505505
extra_headers: Headers | None = None,
@@ -572,7 +572,7 @@ async def get_by_tags(
572572
self,
573573
provider: Literal["notion", "google-drive", "onedrive"],
574574
*,
575-
container_tags: List[str],
575+
container_tags: SequenceNotStr[str],
576576
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
577577
# The extra values given here take precedence over values defined on the client or passed to this method.
578578
extra_headers: Headers | None = None,
@@ -611,7 +611,7 @@ async def import_(
611611
self,
612612
provider: Literal["notion", "google-drive", "onedrive"],
613613
*,
614-
container_tags: List[str] | NotGiven = NOT_GIVEN,
614+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
615615
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
616616
# The extra values given here take precedence over values defined on the client or passed to this method.
617617
extra_headers: Headers | None = None,
@@ -651,7 +651,7 @@ async def list_documents(
651651
self,
652652
provider: Literal["notion", "google-drive", "onedrive"],
653653
*,
654-
container_tags: List[str] | NotGiven = NOT_GIVEN,
654+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
655655
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
656656
# The extra values given here take precedence over values defined on the client or passed to this method.
657657
extra_headers: Headers | None = None,

src/supermemory/resources/memories.py

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

33
from __future__ import annotations
44

5-
from typing import Dict, List, Union, Mapping, cast
5+
from typing import Dict, Union, Mapping, cast
66
from typing_extensions import Literal
77

88
import httpx
99

1010
from ..types import memory_add_params, memory_list_params, memory_update_params, memory_upload_file_params
11-
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, FileTypes
11+
from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven, FileTypes, SequenceNotStr
1212
from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
1313
from .._compat import cached_property
1414
from .._resource import SyncAPIResource, AsyncAPIResource
@@ -53,10 +53,10 @@ def update(
5353
id: str,
5454
*,
5555
container_tag: str | NotGiven = NOT_GIVEN,
56-
container_tags: List[str] | NotGiven = NOT_GIVEN,
56+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
5757
content: str | NotGiven = NOT_GIVEN,
5858
custom_id: str | NotGiven = NOT_GIVEN,
59-
metadata: Dict[str, Union[str, float, bool, List[str]]] | NotGiven = NOT_GIVEN,
59+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | NotGiven = NOT_GIVEN,
6060
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6161
# The extra values given here take precedence over values defined on the client or passed to this method.
6262
extra_headers: Headers | None = None,
@@ -124,7 +124,7 @@ def update(
124124
def list(
125125
self,
126126
*,
127-
container_tags: List[str] | NotGiven = NOT_GIVEN,
127+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
128128
filters: str | NotGiven = NOT_GIVEN,
129129
include_content: bool | NotGiven = NOT_GIVEN,
130130
limit: Union[str, float] | NotGiven = NOT_GIVEN,
@@ -224,10 +224,10 @@ def add(
224224
self,
225225
*,
226226
container_tag: str | NotGiven = NOT_GIVEN,
227-
container_tags: List[str] | NotGiven = NOT_GIVEN,
227+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
228228
content: str | NotGiven = NOT_GIVEN,
229229
custom_id: str | NotGiven = NOT_GIVEN,
230-
metadata: Dict[str, Union[str, float, bool, List[str]]] | NotGiven = NOT_GIVEN,
230+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | NotGiven = NOT_GIVEN,
231231
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
232232
# The extra values given here take precedence over values defined on the client or passed to this method.
233233
extra_headers: Headers | None = None,
@@ -394,10 +394,10 @@ async def update(
394394
id: str,
395395
*,
396396
container_tag: str | NotGiven = NOT_GIVEN,
397-
container_tags: List[str] | NotGiven = NOT_GIVEN,
397+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
398398
content: str | NotGiven = NOT_GIVEN,
399399
custom_id: str | NotGiven = NOT_GIVEN,
400-
metadata: Dict[str, Union[str, float, bool, List[str]]] | NotGiven = NOT_GIVEN,
400+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | NotGiven = NOT_GIVEN,
401401
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
402402
# The extra values given here take precedence over values defined on the client or passed to this method.
403403
extra_headers: Headers | None = None,
@@ -465,7 +465,7 @@ async def update(
465465
async def list(
466466
self,
467467
*,
468-
container_tags: List[str] | NotGiven = NOT_GIVEN,
468+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
469469
filters: str | NotGiven = NOT_GIVEN,
470470
include_content: bool | NotGiven = NOT_GIVEN,
471471
limit: Union[str, float] | NotGiven = NOT_GIVEN,
@@ -565,10 +565,10 @@ async def add(
565565
self,
566566
*,
567567
container_tag: str | NotGiven = NOT_GIVEN,
568-
container_tags: List[str] | NotGiven = NOT_GIVEN,
568+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
569569
content: str | NotGiven = NOT_GIVEN,
570570
custom_id: str | NotGiven = NOT_GIVEN,
571-
metadata: Dict[str, Union[str, float, bool, List[str]]] | NotGiven = NOT_GIVEN,
571+
metadata: Dict[str, Union[str, float, bool, SequenceNotStr[str]]] | NotGiven = NOT_GIVEN,
572572
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
573573
# The extra values given here take precedence over values defined on the client or passed to this method.
574574
extra_headers: Headers | None = None,

src/supermemory/resources/search.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import httpx
99

1010
from ..types import search_execute_params, search_memories_params, search_documents_params
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
@@ -52,7 +52,7 @@ def documents(
5252
q: str,
5353
categories_filter: List[Literal["technology", "science", "business", "health"]] | NotGiven = NOT_GIVEN,
5454
chunk_threshold: float | NotGiven = NOT_GIVEN,
55-
container_tags: List[str] | NotGiven = NOT_GIVEN,
55+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
5656
doc_id: str | NotGiven = NOT_GIVEN,
5757
document_threshold: float | NotGiven = NOT_GIVEN,
5858
filters: search_documents_params.Filters | NotGiven = NOT_GIVEN,
@@ -151,7 +151,7 @@ def execute(
151151
q: str,
152152
categories_filter: List[Literal["technology", "science", "business", "health"]] | NotGiven = NOT_GIVEN,
153153
chunk_threshold: float | NotGiven = NOT_GIVEN,
154-
container_tags: List[str] | NotGiven = NOT_GIVEN,
154+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
155155
doc_id: str | NotGiven = NOT_GIVEN,
156156
document_threshold: float | NotGiven = NOT_GIVEN,
157157
filters: search_execute_params.Filters | NotGiven = NOT_GIVEN,
@@ -341,7 +341,7 @@ async def documents(
341341
q: str,
342342
categories_filter: List[Literal["technology", "science", "business", "health"]] | NotGiven = NOT_GIVEN,
343343
chunk_threshold: float | NotGiven = NOT_GIVEN,
344-
container_tags: List[str] | NotGiven = NOT_GIVEN,
344+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
345345
doc_id: str | NotGiven = NOT_GIVEN,
346346
document_threshold: float | NotGiven = NOT_GIVEN,
347347
filters: search_documents_params.Filters | NotGiven = NOT_GIVEN,
@@ -440,7 +440,7 @@ async def execute(
440440
q: str,
441441
categories_filter: List[Literal["technology", "science", "business", "health"]] | NotGiven = NOT_GIVEN,
442442
chunk_threshold: float | NotGiven = NOT_GIVEN,
443-
container_tags: List[str] | NotGiven = NOT_GIVEN,
443+
container_tags: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
444444
doc_id: str | NotGiven = NOT_GIVEN,
445445
document_threshold: float | NotGiven = NOT_GIVEN,
446446
filters: search_execute_params.Filters | NotGiven = NOT_GIVEN,

src/supermemory/types/connection_create_params.py

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

33
from __future__ import annotations
44

5-
from typing import Dict, List, Union, Optional
5+
from typing import Dict, Union, Optional
66
from typing_extensions import Annotated, TypedDict
77

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

1011
__all__ = ["ConnectionCreateParams"]
1112

1213

1314
class ConnectionCreateParams(TypedDict, total=False):
14-
container_tags: Annotated[List[str], PropertyInfo(alias="containerTags")]
15+
container_tags: Annotated[SequenceNotStr[str], PropertyInfo(alias="containerTags")]
1516

1617
document_limit: Annotated[int, PropertyInfo(alias="documentLimit")]
1718

src/supermemory/types/connection_delete_by_provider_params.py

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

33
from __future__ import annotations
44

5-
from typing import List
65
from typing_extensions import Required, Annotated, TypedDict
76

7+
from .._types import SequenceNotStr
88
from .._utils import PropertyInfo
99

1010
__all__ = ["ConnectionDeleteByProviderParams"]
1111

1212

1313
class ConnectionDeleteByProviderParams(TypedDict, total=False):
14-
container_tags: Required[Annotated[List[str], PropertyInfo(alias="containerTags")]]
14+
container_tags: Required[Annotated[SequenceNotStr[str], PropertyInfo(alias="containerTags")]]
1515
"""Optional comma-separated list of container tags to filter connections by"""

src/supermemory/types/connection_get_by_tags_params.py

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

33
from __future__ import annotations
44

5-
from typing import List
65
from typing_extensions import Required, Annotated, TypedDict
76

7+
from .._types import SequenceNotStr
88
from .._utils import PropertyInfo
99

1010
__all__ = ["ConnectionGetByTagsParams"]
1111

1212

1313
class ConnectionGetByTagsParams(TypedDict, total=False):
14-
container_tags: Required[Annotated[List[str], PropertyInfo(alias="containerTags")]]
14+
container_tags: Required[Annotated[SequenceNotStr[str], PropertyInfo(alias="containerTags")]]
1515
"""Comma-separated list of container tags to filter connection by"""

src/supermemory/types/connection_import_params.py

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

33
from __future__ import annotations
44

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

7+
from .._types import SequenceNotStr
88
from .._utils import PropertyInfo
99

1010
__all__ = ["ConnectionImportParams"]
1111

1212

1313
class ConnectionImportParams(TypedDict, total=False):
14-
container_tags: Annotated[List[str], PropertyInfo(alias="containerTags")]
14+
container_tags: Annotated[SequenceNotStr[str], PropertyInfo(alias="containerTags")]
1515
"""Optional comma-separated list of container tags to filter connections by"""

src/supermemory/types/connection_list_documents_params.py

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

33
from __future__ import annotations
44

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

7+
from .._types import SequenceNotStr
88
from .._utils import PropertyInfo
99

1010
__all__ = ["ConnectionListDocumentsParams"]
1111

1212

1313
class ConnectionListDocumentsParams(TypedDict, total=False):
14-
container_tags: Annotated[List[str], PropertyInfo(alias="containerTags")]
14+
container_tags: Annotated[SequenceNotStr[str], PropertyInfo(alias="containerTags")]
1515
"""Optional comma-separated list of container tags to filter documents by"""

src/supermemory/types/connection_list_params.py

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

33
from __future__ import annotations
44

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

7+
from .._types import SequenceNotStr
88
from .._utils import PropertyInfo
99

1010
__all__ = ["ConnectionListParams"]
1111

1212

1313
class ConnectionListParams(TypedDict, total=False):
14-
container_tags: Annotated[List[str], PropertyInfo(alias="containerTags")]
14+
container_tags: Annotated[SequenceNotStr[str], PropertyInfo(alias="containerTags")]
1515
"""Optional comma-separated list of container tags to filter documents by"""

0 commit comments

Comments
 (0)