channel3-sdk 2.1.0__py3-none-any.whl → 2.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of channel3-sdk might be problematic. Click here for more details.

channel3_sdk/__init__.py CHANGED
@@ -3,10 +3,9 @@
3
3
  import typing as _t
4
4
 
5
5
  from . import types
6
- from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
6
+ from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
7
7
  from ._utils import file_from_path
8
8
  from ._client import (
9
- ENVIRONMENTS,
10
9
  Client,
11
10
  Stream,
12
11
  Timeout,
@@ -49,7 +48,9 @@ __all__ = [
49
48
  "ProxiesTypes",
50
49
  "NotGiven",
51
50
  "NOT_GIVEN",
51
+ "not_given",
52
52
  "Omit",
53
+ "omit",
53
54
  "Channel3Error",
54
55
  "APIError",
55
56
  "APIStatusError",
@@ -72,7 +73,6 @@ __all__ = [
72
73
  "AsyncStream",
73
74
  "Channel3",
74
75
  "AsyncChannel3",
75
- "ENVIRONMENTS",
76
76
  "file_from_path",
77
77
  "BaseModel",
78
78
  "DEFAULT_TIMEOUT",
@@ -42,7 +42,6 @@ from . import _exceptions
42
42
  from ._qs import Querystring
43
43
  from ._files import to_httpx_files, async_to_httpx_files
44
44
  from ._types import (
45
- NOT_GIVEN,
46
45
  Body,
47
46
  Omit,
48
47
  Query,
@@ -57,6 +56,7 @@ from ._types import (
57
56
  RequestOptions,
58
57
  HttpxRequestFiles,
59
58
  ModelBuilderProtocol,
59
+ not_given,
60
60
  )
61
61
  from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
62
62
  from ._compat import PYDANTIC_V1, model_copy, model_dump
@@ -145,9 +145,9 @@ class PageInfo:
145
145
  def __init__(
146
146
  self,
147
147
  *,
148
- url: URL | NotGiven = NOT_GIVEN,
149
- json: Body | NotGiven = NOT_GIVEN,
150
- params: Query | NotGiven = NOT_GIVEN,
148
+ url: URL | NotGiven = not_given,
149
+ json: Body | NotGiven = not_given,
150
+ params: Query | NotGiven = not_given,
151
151
  ) -> None:
152
152
  self.url = url
153
153
  self.json = json
@@ -595,7 +595,7 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
595
595
  # we internally support defining a temporary header to override the
596
596
  # default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response`
597
597
  # see _response.py for implementation details
598
- override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, NOT_GIVEN)
598
+ override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, not_given)
599
599
  if is_given(override_cast_to):
600
600
  options.headers = headers
601
601
  return cast(Type[ResponseT], override_cast_to)
@@ -825,7 +825,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
825
825
  version: str,
826
826
  base_url: str | URL,
827
827
  max_retries: int = DEFAULT_MAX_RETRIES,
828
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
828
+ timeout: float | Timeout | None | NotGiven = not_given,
829
829
  http_client: httpx.Client | None = None,
830
830
  custom_headers: Mapping[str, str] | None = None,
831
831
  custom_query: Mapping[str, object] | None = None,
@@ -1356,7 +1356,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1356
1356
  base_url: str | URL,
1357
1357
  _strict_response_validation: bool,
1358
1358
  max_retries: int = DEFAULT_MAX_RETRIES,
1359
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
1359
+ timeout: float | Timeout | None | NotGiven = not_given,
1360
1360
  http_client: httpx.AsyncClient | None = None,
1361
1361
  custom_headers: Mapping[str, str] | None = None,
1362
1362
  custom_query: Mapping[str, object] | None = None,
@@ -1818,8 +1818,8 @@ def make_request_options(
1818
1818
  extra_query: Query | None = None,
1819
1819
  extra_body: Body | None = None,
1820
1820
  idempotency_key: str | None = None,
1821
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1822
- post_parser: PostParser | NotGiven = NOT_GIVEN,
1821
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
1822
+ post_parser: PostParser | NotGiven = not_given,
1823
1823
  ) -> RequestOptions:
1824
1824
  """Create a dict of type RequestOptions without keys of NotGiven values."""
1825
1825
  options: RequestOptions = {}
channel3_sdk/_client.py CHANGED
@@ -3,15 +3,14 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import os
6
- from typing import Any, Dict, Union, Mapping, cast
7
- from typing_extensions import Self, Literal, override
6
+ from typing import Any, Mapping
7
+ from typing_extensions import Self, override
8
8
 
9
9
  import httpx
10
10
 
11
11
  from . import _exceptions
12
12
  from ._qs import Querystring
13
13
  from ._types import (
14
- NOT_GIVEN,
15
14
  Body,
16
15
  Omit,
17
16
  Query,
@@ -21,6 +20,7 @@ from ._types import (
21
20
  Transport,
22
21
  ProxiesTypes,
23
22
  RequestOptions,
23
+ not_given,
24
24
  )
25
25
  from ._utils import is_given, get_async_library
26
26
  from ._version import __version__
@@ -41,7 +41,6 @@ from ._base_client import (
41
41
  )
42
42
 
43
43
  __all__ = [
44
- "ENVIRONMENTS",
45
44
  "Timeout",
46
45
  "Transport",
47
46
  "ProxiesTypes",
@@ -52,11 +51,6 @@ __all__ = [
52
51
  "AsyncClient",
53
52
  ]
54
53
 
55
- ENVIRONMENTS: Dict[str, str] = {
56
- "production": "https://api.trychannel3.com",
57
- "development": "https://localhost:8000",
58
- }
59
-
60
54
 
61
55
  class Channel3(SyncAPIClient):
62
56
  search: search.SearchResource
@@ -69,15 +63,12 @@ class Channel3(SyncAPIClient):
69
63
  # client options
70
64
  api_key: str
71
65
 
72
- _environment: Literal["production", "development"] | NotGiven
73
-
74
66
  def __init__(
75
67
  self,
76
68
  *,
77
69
  api_key: str | None = None,
78
- environment: Literal["production", "development"] | NotGiven = NOT_GIVEN,
79
- base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
80
- timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
70
+ base_url: str | httpx.URL | None = None,
71
+ timeout: float | Timeout | None | NotGiven = not_given,
81
72
  max_retries: int = DEFAULT_MAX_RETRIES,
82
73
  default_headers: Mapping[str, str] | None = None,
83
74
  default_query: Mapping[str, object] | None = None,
@@ -107,31 +98,10 @@ class Channel3(SyncAPIClient):
107
98
  )
108
99
  self.api_key = api_key
109
100
 
110
- self._environment = environment
111
-
112
- base_url_env = os.environ.get("CHANNEL3_BASE_URL")
113
- if is_given(base_url) and base_url is not None:
114
- # cast required because mypy doesn't understand the type narrowing
115
- base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
116
- elif is_given(environment):
117
- if base_url_env and base_url is not None:
118
- raise ValueError(
119
- "Ambiguous URL; The `CHANNEL3_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
120
- )
121
-
122
- try:
123
- base_url = ENVIRONMENTS[environment]
124
- except KeyError as exc:
125
- raise ValueError(f"Unknown environment: {environment}") from exc
126
- elif base_url_env is not None:
127
- base_url = base_url_env
128
- else:
129
- self._environment = environment = "production"
130
-
131
- try:
132
- base_url = ENVIRONMENTS[environment]
133
- except KeyError as exc:
134
- raise ValueError(f"Unknown environment: {environment}") from exc
101
+ if base_url is None:
102
+ base_url = os.environ.get("CHANNEL3_BASE_URL")
103
+ if base_url is None:
104
+ base_url = f"https://api.trychannel3.com"
135
105
 
136
106
  super().__init__(
137
107
  version=__version__,
@@ -175,11 +145,10 @@ class Channel3(SyncAPIClient):
175
145
  self,
176
146
  *,
177
147
  api_key: str | None = None,
178
- environment: Literal["production", "development"] | None = None,
179
148
  base_url: str | httpx.URL | None = None,
180
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
149
+ timeout: float | Timeout | None | NotGiven = not_given,
181
150
  http_client: httpx.Client | None = None,
182
- max_retries: int | NotGiven = NOT_GIVEN,
151
+ max_retries: int | NotGiven = not_given,
183
152
  default_headers: Mapping[str, str] | None = None,
184
153
  set_default_headers: Mapping[str, str] | None = None,
185
154
  default_query: Mapping[str, object] | None = None,
@@ -211,7 +180,6 @@ class Channel3(SyncAPIClient):
211
180
  return self.__class__(
212
181
  api_key=api_key or self.api_key,
213
182
  base_url=base_url or self.base_url,
214
- environment=environment or self._environment,
215
183
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
216
184
  http_client=http_client,
217
185
  max_retries=max_retries if is_given(max_retries) else self.max_retries,
@@ -232,7 +200,7 @@ class Channel3(SyncAPIClient):
232
200
  extra_headers: Headers | None = None,
233
201
  extra_query: Query | None = None,
234
202
  extra_body: Body | None = None,
235
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
203
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
236
204
  ) -> object:
237
205
  """Root"""
238
206
  return self.get(
@@ -288,15 +256,12 @@ class AsyncChannel3(AsyncAPIClient):
288
256
  # client options
289
257
  api_key: str
290
258
 
291
- _environment: Literal["production", "development"] | NotGiven
292
-
293
259
  def __init__(
294
260
  self,
295
261
  *,
296
262
  api_key: str | None = None,
297
- environment: Literal["production", "development"] | NotGiven = NOT_GIVEN,
298
- base_url: str | httpx.URL | None | NotGiven = NOT_GIVEN,
299
- timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
263
+ base_url: str | httpx.URL | None = None,
264
+ timeout: float | Timeout | None | NotGiven = not_given,
300
265
  max_retries: int = DEFAULT_MAX_RETRIES,
301
266
  default_headers: Mapping[str, str] | None = None,
302
267
  default_query: Mapping[str, object] | None = None,
@@ -326,31 +291,10 @@ class AsyncChannel3(AsyncAPIClient):
326
291
  )
327
292
  self.api_key = api_key
328
293
 
329
- self._environment = environment
330
-
331
- base_url_env = os.environ.get("CHANNEL3_BASE_URL")
332
- if is_given(base_url) and base_url is not None:
333
- # cast required because mypy doesn't understand the type narrowing
334
- base_url = cast("str | httpx.URL", base_url) # pyright: ignore[reportUnnecessaryCast]
335
- elif is_given(environment):
336
- if base_url_env and base_url is not None:
337
- raise ValueError(
338
- "Ambiguous URL; The `CHANNEL3_BASE_URL` env var and the `environment` argument are given. If you want to use the environment, you must pass base_url=None",
339
- )
340
-
341
- try:
342
- base_url = ENVIRONMENTS[environment]
343
- except KeyError as exc:
344
- raise ValueError(f"Unknown environment: {environment}") from exc
345
- elif base_url_env is not None:
346
- base_url = base_url_env
347
- else:
348
- self._environment = environment = "production"
349
-
350
- try:
351
- base_url = ENVIRONMENTS[environment]
352
- except KeyError as exc:
353
- raise ValueError(f"Unknown environment: {environment}") from exc
294
+ if base_url is None:
295
+ base_url = os.environ.get("CHANNEL3_BASE_URL")
296
+ if base_url is None:
297
+ base_url = f"https://api.trychannel3.com"
354
298
 
355
299
  super().__init__(
356
300
  version=__version__,
@@ -394,11 +338,10 @@ class AsyncChannel3(AsyncAPIClient):
394
338
  self,
395
339
  *,
396
340
  api_key: str | None = None,
397
- environment: Literal["production", "development"] | None = None,
398
341
  base_url: str | httpx.URL | None = None,
399
- timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
342
+ timeout: float | Timeout | None | NotGiven = not_given,
400
343
  http_client: httpx.AsyncClient | None = None,
401
- max_retries: int | NotGiven = NOT_GIVEN,
344
+ max_retries: int | NotGiven = not_given,
402
345
  default_headers: Mapping[str, str] | None = None,
403
346
  set_default_headers: Mapping[str, str] | None = None,
404
347
  default_query: Mapping[str, object] | None = None,
@@ -430,7 +373,6 @@ class AsyncChannel3(AsyncAPIClient):
430
373
  return self.__class__(
431
374
  api_key=api_key or self.api_key,
432
375
  base_url=base_url or self.base_url,
433
- environment=environment or self._environment,
434
376
  timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
435
377
  http_client=http_client,
436
378
  max_retries=max_retries if is_given(max_retries) else self.max_retries,
@@ -451,7 +393,7 @@ class AsyncChannel3(AsyncAPIClient):
451
393
  extra_headers: Headers | None = None,
452
394
  extra_query: Query | None = None,
453
395
  extra_body: Body | None = None,
454
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
396
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
455
397
  ) -> object:
456
398
  """Root"""
457
399
  return await self.get(
channel3_sdk/_models.py CHANGED
@@ -256,7 +256,7 @@ class BaseModel(pydantic.BaseModel):
256
256
  mode: Literal["json", "python"] | str = "python",
257
257
  include: IncEx | None = None,
258
258
  exclude: IncEx | None = None,
259
- by_alias: bool = False,
259
+ by_alias: bool | None = None,
260
260
  exclude_unset: bool = False,
261
261
  exclude_defaults: bool = False,
262
262
  exclude_none: bool = False,
@@ -264,6 +264,7 @@ class BaseModel(pydantic.BaseModel):
264
264
  warnings: bool | Literal["none", "warn", "error"] = True,
265
265
  context: dict[str, Any] | None = None,
266
266
  serialize_as_any: bool = False,
267
+ fallback: Callable[[Any], Any] | None = None,
267
268
  ) -> dict[str, Any]:
268
269
  """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump
269
270
 
@@ -295,10 +296,12 @@ class BaseModel(pydantic.BaseModel):
295
296
  raise ValueError("context is only supported in Pydantic v2")
296
297
  if serialize_as_any != False:
297
298
  raise ValueError("serialize_as_any is only supported in Pydantic v2")
299
+ if fallback is not None:
300
+ raise ValueError("fallback is only supported in Pydantic v2")
298
301
  dumped = super().dict( # pyright: ignore[reportDeprecated]
299
302
  include=include,
300
303
  exclude=exclude,
301
- by_alias=by_alias,
304
+ by_alias=by_alias if by_alias is not None else False,
302
305
  exclude_unset=exclude_unset,
303
306
  exclude_defaults=exclude_defaults,
304
307
  exclude_none=exclude_none,
@@ -313,13 +316,14 @@ class BaseModel(pydantic.BaseModel):
313
316
  indent: int | None = None,
314
317
  include: IncEx | None = None,
315
318
  exclude: IncEx | None = None,
316
- by_alias: bool = False,
319
+ by_alias: bool | None = None,
317
320
  exclude_unset: bool = False,
318
321
  exclude_defaults: bool = False,
319
322
  exclude_none: bool = False,
320
323
  round_trip: bool = False,
321
324
  warnings: bool | Literal["none", "warn", "error"] = True,
322
325
  context: dict[str, Any] | None = None,
326
+ fallback: Callable[[Any], Any] | None = None,
323
327
  serialize_as_any: bool = False,
324
328
  ) -> str:
325
329
  """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json
@@ -348,11 +352,13 @@ class BaseModel(pydantic.BaseModel):
348
352
  raise ValueError("context is only supported in Pydantic v2")
349
353
  if serialize_as_any != False:
350
354
  raise ValueError("serialize_as_any is only supported in Pydantic v2")
355
+ if fallback is not None:
356
+ raise ValueError("fallback is only supported in Pydantic v2")
351
357
  return super().json( # type: ignore[reportDeprecated]
352
358
  indent=indent,
353
359
  include=include,
354
360
  exclude=exclude,
355
- by_alias=by_alias,
361
+ by_alias=by_alias if by_alias is not None else False,
356
362
  exclude_unset=exclude_unset,
357
363
  exclude_defaults=exclude_defaults,
358
364
  exclude_none=exclude_none,
channel3_sdk/_qs.py CHANGED
@@ -4,7 +4,7 @@ from typing import Any, List, Tuple, Union, Mapping, TypeVar
4
4
  from urllib.parse import parse_qs, urlencode
5
5
  from typing_extensions import Literal, get_args
6
6
 
7
- from ._types import NOT_GIVEN, NotGiven, NotGivenOr
7
+ from ._types import NotGiven, not_given
8
8
  from ._utils import flatten
9
9
 
10
10
  _T = TypeVar("_T")
@@ -41,8 +41,8 @@ class Querystring:
41
41
  self,
42
42
  params: Params,
43
43
  *,
44
- array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN,
45
- nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN,
44
+ array_format: ArrayFormat | NotGiven = not_given,
45
+ nested_format: NestedFormat | NotGiven = not_given,
46
46
  ) -> str:
47
47
  return urlencode(
48
48
  self.stringify_items(
@@ -56,8 +56,8 @@ class Querystring:
56
56
  self,
57
57
  params: Params,
58
58
  *,
59
- array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN,
60
- nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN,
59
+ array_format: ArrayFormat | NotGiven = not_given,
60
+ nested_format: NestedFormat | NotGiven = not_given,
61
61
  ) -> list[tuple[str, str]]:
62
62
  opts = Options(
63
63
  qs=self,
@@ -143,8 +143,8 @@ class Options:
143
143
  self,
144
144
  qs: Querystring = _qs,
145
145
  *,
146
- array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN,
147
- nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN,
146
+ array_format: ArrayFormat | NotGiven = not_given,
147
+ nested_format: NestedFormat | NotGiven = not_given,
148
148
  ) -> None:
149
149
  self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format
150
150
  self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format
channel3_sdk/_types.py CHANGED
@@ -117,18 +117,21 @@ class RequestOptions(TypedDict, total=False):
117
117
  # Sentinel class used until PEP 0661 is accepted
118
118
  class NotGiven:
119
119
  """
120
- A sentinel singleton class used to distinguish omitted keyword arguments
121
- from those passed in with the value None (which may have different behavior).
120
+ For parameters with a meaningful None value, we need to distinguish between
121
+ the user explicitly passing None, and the user not passing the parameter at
122
+ all.
123
+
124
+ User code shouldn't need to use not_given directly.
122
125
 
123
126
  For example:
124
127
 
125
128
  ```py
126
- def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ...
129
+ def create(timeout: Timeout | None | NotGiven = not_given): ...
127
130
 
128
131
 
129
- get(timeout=1) # 1s timeout
130
- get(timeout=None) # No timeout
131
- get() # Default timeout behavior, which may not be statically known at the method definition.
132
+ create(timeout=1) # 1s timeout
133
+ create(timeout=None) # No timeout
134
+ create() # Default timeout behavior
132
135
  ```
133
136
  """
134
137
 
@@ -140,13 +143,14 @@ class NotGiven:
140
143
  return "NOT_GIVEN"
141
144
 
142
145
 
143
- NotGivenOr = Union[_T, NotGiven]
146
+ not_given = NotGiven()
147
+ # for backwards compatibility:
144
148
  NOT_GIVEN = NotGiven()
145
149
 
146
150
 
147
151
  class Omit:
148
- """In certain situations you need to be able to represent a case where a default value has
149
- to be explicitly removed and `None` is not an appropriate substitute, for example:
152
+ """
153
+ To explicitly omit something from being sent in a request, use `omit`.
150
154
 
151
155
  ```py
152
156
  # as the default `Content-Type` header is `application/json` that will be sent
@@ -156,8 +160,8 @@ class Omit:
156
160
  # to look something like: 'multipart/form-data; boundary=0d8382fcf5f8c3be01ca2e11002d2983'
157
161
  client.post(..., headers={"Content-Type": "multipart/form-data"})
158
162
 
159
- # instead you can remove the default `application/json` header by passing Omit
160
- client.post(..., headers={"Content-Type": Omit()})
163
+ # instead you can remove the default `application/json` header by passing omit
164
+ client.post(..., headers={"Content-Type": omit})
161
165
  ```
162
166
  """
163
167
 
@@ -165,6 +169,9 @@ class Omit:
165
169
  return False
166
170
 
167
171
 
172
+ omit = Omit()
173
+
174
+
168
175
  @runtime_checkable
169
176
  class ModelBuilderProtocol(Protocol):
170
177
  @classmethod
@@ -268,7 +268,7 @@ def _transform_typeddict(
268
268
  annotations = get_type_hints(expected_type, include_extras=True)
269
269
  for key, value in data.items():
270
270
  if not is_given(value):
271
- # we don't need to include `NotGiven` values here as they'll
271
+ # we don't need to include omitted values here as they'll
272
272
  # be stripped out before the request is sent anyway
273
273
  continue
274
274
 
@@ -434,7 +434,7 @@ async def _async_transform_typeddict(
434
434
  annotations = get_type_hints(expected_type, include_extras=True)
435
435
  for key, value in data.items():
436
436
  if not is_given(value):
437
- # we don't need to include `NotGiven` values here as they'll
437
+ # we don't need to include omitted values here as they'll
438
438
  # be stripped out before the request is sent anyway
439
439
  continue
440
440
 
@@ -21,7 +21,7 @@ from typing_extensions import TypeGuard
21
21
 
22
22
  import sniffio
23
23
 
24
- from .._types import NotGiven, FileTypes, NotGivenOr, HeadersLike
24
+ from .._types import Omit, NotGiven, FileTypes, HeadersLike
25
25
 
26
26
  _T = TypeVar("_T")
27
27
  _TupleT = TypeVar("_TupleT", bound=Tuple[object, ...])
@@ -63,7 +63,7 @@ def _extract_items(
63
63
  try:
64
64
  key = path[index]
65
65
  except IndexError:
66
- if isinstance(obj, NotGiven):
66
+ if not is_given(obj):
67
67
  # no value was provided - we can safely ignore
68
68
  return []
69
69
 
@@ -126,8 +126,8 @@ def _extract_items(
126
126
  return []
127
127
 
128
128
 
129
- def is_given(obj: NotGivenOr[_T]) -> TypeGuard[_T]:
130
- return not isinstance(obj, NotGiven)
129
+ def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]:
130
+ return not isinstance(obj, NotGiven) and not isinstance(obj, Omit)
131
131
 
132
132
 
133
133
  # Type safe methods for narrowing types with TypeVars.
channel3_sdk/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "channel3_sdk"
4
- __version__ = "2.1.0" # x-release-please-version
4
+ __version__ = "2.2.1" # x-release-please-version
@@ -7,7 +7,7 @@ from typing import Optional
7
7
  import httpx
8
8
 
9
9
  from ..types import brand_list_params
10
- from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10
+ from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
11
11
  from .._utils import maybe_transform, async_maybe_transform
12
12
  from .._compat import cached_property
13
13
  from .._resource import SyncAPIResource, AsyncAPIResource
@@ -53,7 +53,7 @@ class BrandsResource(SyncAPIResource):
53
53
  extra_headers: Headers | None = None,
54
54
  extra_query: Query | None = None,
55
55
  extra_body: Body | None = None,
56
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
56
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
57
57
  ) -> Brand:
58
58
  """
59
59
  Get detailed information for a specific brand by its ID.
@@ -80,15 +80,15 @@ class BrandsResource(SyncAPIResource):
80
80
  def list(
81
81
  self,
82
82
  *,
83
- page: int | NotGiven = NOT_GIVEN,
84
- query: Optional[str] | NotGiven = NOT_GIVEN,
85
- size: int | NotGiven = NOT_GIVEN,
83
+ page: int | Omit = omit,
84
+ query: Optional[str] | Omit = omit,
85
+ size: int | Omit = omit,
86
86
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
87
87
  # The extra values given here take precedence over values defined on the client or passed to this method.
88
88
  extra_headers: Headers | None = None,
89
89
  extra_query: Query | None = None,
90
90
  extra_body: Body | None = None,
91
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
91
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
92
92
  ) -> BrandListResponse:
93
93
  """
94
94
  Get all brands that the vendor currently sells.
@@ -151,7 +151,7 @@ class AsyncBrandsResource(AsyncAPIResource):
151
151
  extra_headers: Headers | None = None,
152
152
  extra_query: Query | None = None,
153
153
  extra_body: Body | None = None,
154
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
154
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
155
155
  ) -> Brand:
156
156
  """
157
157
  Get detailed information for a specific brand by its ID.
@@ -178,15 +178,15 @@ class AsyncBrandsResource(AsyncAPIResource):
178
178
  async def list(
179
179
  self,
180
180
  *,
181
- page: int | NotGiven = NOT_GIVEN,
182
- query: Optional[str] | NotGiven = NOT_GIVEN,
183
- size: int | NotGiven = NOT_GIVEN,
181
+ page: int | Omit = omit,
182
+ query: Optional[str] | Omit = omit,
183
+ size: int | Omit = omit,
184
184
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
185
185
  # The extra values given here take precedence over values defined on the client or passed to this method.
186
186
  extra_headers: Headers | None = None,
187
187
  extra_query: Query | None = None,
188
188
  extra_body: Body | None = None,
189
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
189
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
190
190
  ) -> BrandListResponse:
191
191
  """
192
192
  Get all brands that the vendor currently sells.
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  import httpx
6
6
 
7
7
  from ..types import enrich_enrich_url_params
8
- from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
8
+ from .._types import Body, Query, Headers, NotGiven, not_given
9
9
  from .._utils import maybe_transform, async_maybe_transform
10
10
  from .._compat import cached_property
11
11
  from .._resource import SyncAPIResource, AsyncAPIResource
@@ -50,7 +50,7 @@ class EnrichResource(SyncAPIResource):
50
50
  extra_headers: Headers | None = None,
51
51
  extra_query: Query | None = None,
52
52
  extra_body: Body | None = None,
53
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
53
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
54
54
  ) -> EnrichEnrichURLResponse:
55
55
  """
56
56
  Enrich a product URL with additional information.
@@ -105,7 +105,7 @@ class AsyncEnrichResource(AsyncAPIResource):
105
105
  extra_headers: Headers | None = None,
106
106
  extra_query: Query | None = None,
107
107
  extra_body: Body | None = None,
108
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
108
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
109
109
  ) -> EnrichEnrichURLResponse:
110
110
  """
111
111
  Enrich a product URL with additional information.
@@ -4,7 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  import httpx
6
6
 
7
- from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
7
+ from .._types import Body, Query, Headers, NotGiven, not_given
8
8
  from .._compat import cached_property
9
9
  from .._resource import SyncAPIResource, AsyncAPIResource
10
10
  from .._response import (
@@ -48,7 +48,7 @@ class ProductsResource(SyncAPIResource):
48
48
  extra_headers: Headers | None = None,
49
49
  extra_query: Query | None = None,
50
50
  extra_body: Body | None = None,
51
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
51
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
52
52
  ) -> ProductRetrieveResponse:
53
53
  """
54
54
  Get detailed information about a specific product by its ID.
@@ -102,7 +102,7 @@ class AsyncProductsResource(AsyncAPIResource):
102
102
  extra_headers: Headers | None = None,
103
103
  extra_query: Query | None = None,
104
104
  extra_body: Body | None = None,
105
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
105
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
106
106
  ) -> ProductRetrieveResponse:
107
107
  """
108
108
  Get detailed information about a specific product by its ID.
@@ -7,7 +7,7 @@ from typing import Optional
7
7
  import httpx
8
8
 
9
9
  from ..types import search_perform_params
10
- from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
10
+ from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
11
11
  from .._utils import maybe_transform, async_maybe_transform
12
12
  from .._compat import cached_property
13
13
  from .._resource import SyncAPIResource, AsyncAPIResource
@@ -46,19 +46,19 @@ class SearchResource(SyncAPIResource):
46
46
  def perform(
47
47
  self,
48
48
  *,
49
- base64_image: Optional[str] | NotGiven = NOT_GIVEN,
50
- config: search_perform_params.Config | NotGiven = NOT_GIVEN,
51
- context: Optional[str] | NotGiven = NOT_GIVEN,
52
- filters: search_perform_params.Filters | NotGiven = NOT_GIVEN,
53
- image_url: Optional[str] | NotGiven = NOT_GIVEN,
54
- limit: Optional[int] | NotGiven = NOT_GIVEN,
55
- query: Optional[str] | NotGiven = NOT_GIVEN,
49
+ base64_image: Optional[str] | Omit = omit,
50
+ config: search_perform_params.Config | Omit = omit,
51
+ context: Optional[str] | Omit = omit,
52
+ filters: search_perform_params.Filters | Omit = omit,
53
+ image_url: Optional[str] | Omit = omit,
54
+ limit: Optional[int] | Omit = omit,
55
+ query: Optional[str] | Omit = omit,
56
56
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
57
57
  # The extra values given here take precedence over values defined on the client or passed to this method.
58
58
  extra_headers: Headers | None = None,
59
59
  extra_query: Query | None = None,
60
60
  extra_body: Body | None = None,
61
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
61
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
62
62
  ) -> SearchPerformResponse:
63
63
  """
64
64
  Search for products.
@@ -130,19 +130,19 @@ class AsyncSearchResource(AsyncAPIResource):
130
130
  async def perform(
131
131
  self,
132
132
  *,
133
- base64_image: Optional[str] | NotGiven = NOT_GIVEN,
134
- config: search_perform_params.Config | NotGiven = NOT_GIVEN,
135
- context: Optional[str] | NotGiven = NOT_GIVEN,
136
- filters: search_perform_params.Filters | NotGiven = NOT_GIVEN,
137
- image_url: Optional[str] | NotGiven = NOT_GIVEN,
138
- limit: Optional[int] | NotGiven = NOT_GIVEN,
139
- query: Optional[str] | NotGiven = NOT_GIVEN,
133
+ base64_image: Optional[str] | Omit = omit,
134
+ config: search_perform_params.Config | Omit = omit,
135
+ context: Optional[str] | Omit = omit,
136
+ filters: search_perform_params.Filters | Omit = omit,
137
+ image_url: Optional[str] | Omit = omit,
138
+ limit: Optional[int] | Omit = omit,
139
+ query: Optional[str] | Omit = omit,
140
140
  # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
141
141
  # The extra values given here take precedence over values defined on the client or passed to this method.
142
142
  extra_headers: Headers | None = None,
143
143
  extra_query: Query | None = None,
144
144
  extra_body: Body | None = None,
145
- timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
145
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
146
146
  ) -> SearchPerformResponse:
147
147
  """
148
148
  Search for products.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: channel3_sdk
3
- Version: 2.1.0
3
+ Version: 2.2.1
4
4
  Summary: The official Python library for the channel3 API
5
5
  Project-URL: Homepage, https://github.com/channel3-ai/sdk-python
6
6
  Project-URL: Repository, https://github.com/channel3-ai/sdk-python
@@ -30,7 +30,7 @@ Requires-Dist: sniffio
30
30
  Requires-Dist: typing-extensions<5,>=4.10
31
31
  Provides-Extra: aiohttp
32
32
  Requires-Dist: aiohttp; extra == 'aiohttp'
33
- Requires-Dist: httpx-aiohttp>=0.1.8; extra == 'aiohttp'
33
+ Requires-Dist: httpx-aiohttp>=0.1.9; extra == 'aiohttp'
34
34
  Description-Content-Type: text/markdown
35
35
 
36
36
  # Channel3 Python API library
@@ -65,8 +65,6 @@ from channel3_sdk import Channel3
65
65
 
66
66
  client = Channel3(
67
67
  api_key=os.environ.get("CHANNEL3_API_KEY"), # This is the default and can be omitted
68
- # defaults to "production".
69
- environment="development",
70
68
  )
71
69
 
72
70
  response = client.search.perform()
@@ -88,8 +86,6 @@ from channel3_sdk import AsyncChannel3
88
86
 
89
87
  client = AsyncChannel3(
90
88
  api_key=os.environ.get("CHANNEL3_API_KEY"), # This is the default and can be omitted
91
- # defaults to "production".
92
- environment="development",
93
89
  )
94
90
 
95
91
 
@@ -1,17 +1,17 @@
1
- channel3_sdk/__init__.py,sha256=Xff2HWM1sCneEByTw8g9RtGRj3yxb3qRmUzaS_A8pQ0,2687
2
- channel3_sdk/_base_client.py,sha256=jAazpJA7xqOW0adz0t6NQqnCdA2car1Ltt-hHRWkJO4,67053
3
- channel3_sdk/_client.py,sha256=46O_QGaNZHq2R1MDZPmdgnzjWKXxWY_Dk6XmS2qpNig,21466
1
+ channel3_sdk/__init__.py,sha256=xMt6zqI0MaCwW1vOvuxhpynXr3s4rJhgFx0HD_WlINM,2695
2
+ channel3_sdk/_base_client.py,sha256=nof4xhXvrewcHa-fzhdxoeynZlMcUqe_MwVhs3mdnu8,67053
3
+ channel3_sdk/_client.py,sha256=HPel5F_mRvQBBigdQO1aRPuxXhS1J4L682xLFQpN-SM,18678
4
4
  channel3_sdk/_compat.py,sha256=DQBVORjFb33zch24jzkhM14msvnzY7mmSmgDLaVFUM8,6562
5
5
  channel3_sdk/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
6
6
  channel3_sdk/_exceptions.py,sha256=84j5sMEvg1Y-Zm8O67uKc4VKDZyMyT7UNYql5WGxCQU,3224
7
7
  channel3_sdk/_files.py,sha256=KnEzGi_O756MvKyJ4fOCW_u3JhOeWPQ4RsmDvqihDQU,3545
8
- channel3_sdk/_models.py,sha256=c29x_mRccdxlGwdUPfSR5eJxGXe74Ea5Dje5igZTrKQ,30024
9
- channel3_sdk/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
8
+ channel3_sdk/_models.py,sha256=lKnskYPONAWDvWo8tmbbVk7HmG7UOsI0Nve0vSMmkRc,30452
9
+ channel3_sdk/_qs.py,sha256=craIKyvPktJ94cvf9zn8j8ekG9dWJzhWv0ob34lIOv4,4828
10
10
  channel3_sdk/_resource.py,sha256=GoE4cbZQQeB-svaapj3Xu4BObqkjwbzcd4HbXcti-oc,1112
11
11
  channel3_sdk/_response.py,sha256=fQfICgXh4GiLeIvsMrIRiUo9WIML1AWVhk3D-qkJiVw,28846
12
12
  channel3_sdk/_streaming.py,sha256=q4zuYRWOVScdu0XFwgZle68N1jzSwFd8SbBE4js9hYg,10108
13
- channel3_sdk/_types.py,sha256=vyVmsT14j89c0NFuWlM9KCoRdE1QHrmAGPYZg0fNF3A,7302
14
- channel3_sdk/_version.py,sha256=pB0sWB4VXrlcero6bvLLrfReNMT9G27iM7KTOCt6i6A,164
13
+ channel3_sdk/_types.py,sha256=KHmOPyD0PEi0zdZbUwJwBwPxiFttwJH4uaqh5isWqpU,7242
14
+ channel3_sdk/_version.py,sha256=USrlyrefncO6n8BIO7hpmkSU8nyvyNR2mSnkh5q75H0,164
15
15
  channel3_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  channel3_sdk/_utils/__init__.py,sha256=7fch0GT9zpNnErbciSpUNa-SjTxxjY6kxHxKMOM4AGs,2305
17
17
  channel3_sdk/_utils/_compat.py,sha256=D8gtAvjJQrDWt9upS0XaG9Rr5l1QhiAx_I_1utT_tt0,1195
@@ -22,15 +22,15 @@ channel3_sdk/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QH
22
22
  channel3_sdk/_utils/_resources_proxy.py,sha256=hde_OK_LaNEKEt9ICZ_6kULagtvOt2xb_ma_9_BlxHM,619
23
23
  channel3_sdk/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
24
24
  channel3_sdk/_utils/_sync.py,sha256=TpGLrrhRNWTJtODNE6Fup3_k7zrWm1j2RlirzBwre-0,2862
25
- channel3_sdk/_utils/_transform.py,sha256=i_U4R82RtQJtKKCriwFqmfcWjtwmmsiiF1AEXKQ_OPo,15957
25
+ channel3_sdk/_utils/_transform.py,sha256=NjCzmnfqYrsAikUHQig6N9QfuTVbKipuP3ur9mcNF-E,15951
26
26
  channel3_sdk/_utils/_typing.py,sha256=N_5PPuFNsaygbtA_npZd98SVN1LQQvFTKL6bkWPBZGU,4786
27
- channel3_sdk/_utils/_utils.py,sha256=D2QE7mVPNEJzaB50u8rvDQAUDS5jx7JoeFD7zdj-TeI,12231
27
+ channel3_sdk/_utils/_utils.py,sha256=0dDqauUbVZEXV0NVl7Bwu904Wwo5eyFCZpQThhFNhyA,12253
28
28
  channel3_sdk/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
29
29
  channel3_sdk/resources/__init__.py,sha256=ihYygd79ZVtP7-YyK8aHKXSl-30t2TSDmjMydrK3kug,1928
30
- channel3_sdk/resources/brands.py,sha256=-V8NXfTZdiBlfTfrkr2PzjunaTZCA8fRgvDYUqshyw4,9572
31
- channel3_sdk/resources/enrich.py,sha256=NDdwjECxd2IFTxn3gby6bL3XjK25j900Jw3I4CBEHac,6057
32
- channel3_sdk/resources/products.py,sha256=zsvCo50reb5xi8bwJBmgNGYYXcphfyyayFS_IhQm4_0,6031
33
- channel3_sdk/resources/search.py,sha256=o4BK5qAdosEZqJSAeoJAY7nwwC_pfHTadwfghrIVZRo,8002
30
+ channel3_sdk/resources/brands.py,sha256=kiwvKrJMKHO7oLZ-060L9nNm5OxtvsAh_proQx7amoc,9530
31
+ channel3_sdk/resources/enrich.py,sha256=h1MactdD5DUP0UvEBK7cUF7MUW4jE3W-zLOAzrsyTY8,6057
32
+ channel3_sdk/resources/products.py,sha256=mGFml_kHZ-X_VVfNZHDO9QyZ2ElS1Jk98L6ERokEZqM,6031
33
+ channel3_sdk/resources/search.py,sha256=W74yHSu4TVirEEUx1d-sCL3OK1cUidtoM2MUyERu1qw,7888
34
34
  channel3_sdk/types/__init__.py,sha256=8htzye-XSKQuJAF2zBIPx6nnreh7XbHMcerLnn2Junc,871
35
35
  channel3_sdk/types/availability_status.py,sha256=ZeikDshnsbvDpeqk9zR-DodD0gL_lLKBsjkrSEGmv2A,328
36
36
  channel3_sdk/types/brand.py,sha256=bo0dQfqd8pwzucwAZaW6S1RfRhMipabpQJQTXxJ4q_I,297
@@ -43,7 +43,7 @@ channel3_sdk/types/product_retrieve_response.py,sha256=BJn6JCHfKDnVSbq02ddToT5gT
43
43
  channel3_sdk/types/search_perform_params.py,sha256=WdAOyOCweXMs2hH-q3ts6fw9VNq7cTSq1q-wrWAPuyE,1594
44
44
  channel3_sdk/types/search_perform_response.py,sha256=Px4_wJB9YUUxLoXZzWPpMOjh62No7lWzcenll1K-NnE,721
45
45
  channel3_sdk/types/variant.py,sha256=QcmXSluhHFVXT0QMhITG4iZvS-hl1ngoIev1nswUINc,226
46
- channel3_sdk-2.1.0.dist-info/METADATA,sha256=HztxyAVD5yB7BBvuIFiyqToJfJ9t9t6BwLVCH2Wo5qg,13763
47
- channel3_sdk-2.1.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
48
- channel3_sdk-2.1.0.dist-info/licenses/LICENSE,sha256=pSFglIc4-SNY4qmMqUbuM9ZbSEb8pp67mDMyRI2dN2I,11338
49
- channel3_sdk-2.1.0.dist-info/RECORD,,
46
+ channel3_sdk-2.2.1.dist-info/METADATA,sha256=qurwM_YEIoi6eYkyrP7zmtTjLCW1F9g_tWd5kNM8984,13637
47
+ channel3_sdk-2.2.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
48
+ channel3_sdk-2.2.1.dist-info/licenses/LICENSE,sha256=pSFglIc4-SNY4qmMqUbuM9ZbSEb8pp67mDMyRI2dN2I,11338
49
+ channel3_sdk-2.2.1.dist-info/RECORD,,