isaacus 0.3.2__tar.gz → 0.3.3__tar.gz

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.
Files changed (75) hide show
  1. isaacus-0.3.3/.release-please-manifest.json +3 -0
  2. {isaacus-0.3.2 → isaacus-0.3.3}/CHANGELOG.md +24 -0
  3. {isaacus-0.3.2 → isaacus-0.3.3}/PKG-INFO +1 -1
  4. {isaacus-0.3.2 → isaacus-0.3.3}/pyproject.toml +2 -1
  5. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_base_client.py +10 -1
  6. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_utils/_transform.py +46 -1
  7. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_utils/_typing.py +2 -0
  8. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_version.py +1 -1
  9. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_transform.py +20 -1
  10. isaacus-0.3.2/.release-please-manifest.json +0 -3
  11. {isaacus-0.3.2 → isaacus-0.3.3}/.gitignore +0 -0
  12. {isaacus-0.3.2 → isaacus-0.3.3}/CONTRIBUTING.md +0 -0
  13. {isaacus-0.3.2 → isaacus-0.3.3}/LICENSE +0 -0
  14. {isaacus-0.3.2 → isaacus-0.3.3}/README.md +0 -0
  15. {isaacus-0.3.2 → isaacus-0.3.3}/SECURITY.md +0 -0
  16. {isaacus-0.3.2 → isaacus-0.3.3}/api.md +0 -0
  17. {isaacus-0.3.2 → isaacus-0.3.3}/bin/check-release-environment +0 -0
  18. {isaacus-0.3.2 → isaacus-0.3.3}/bin/publish-pypi +0 -0
  19. {isaacus-0.3.2 → isaacus-0.3.3}/examples/.keep +0 -0
  20. {isaacus-0.3.2 → isaacus-0.3.3}/mypy.ini +0 -0
  21. {isaacus-0.3.2 → isaacus-0.3.3}/noxfile.py +0 -0
  22. {isaacus-0.3.2 → isaacus-0.3.3}/release-please-config.json +0 -0
  23. {isaacus-0.3.2 → isaacus-0.3.3}/requirements-dev.lock +0 -0
  24. {isaacus-0.3.2 → isaacus-0.3.3}/requirements.lock +0 -0
  25. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/__init__.py +0 -0
  26. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_client.py +0 -0
  27. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_compat.py +0 -0
  28. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_constants.py +0 -0
  29. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_exceptions.py +0 -0
  30. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_files.py +0 -0
  31. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_models.py +0 -0
  32. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_qs.py +0 -0
  33. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_resource.py +0 -0
  34. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_response.py +0 -0
  35. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_streaming.py +0 -0
  36. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_types.py +0 -0
  37. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_utils/__init__.py +0 -0
  38. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_utils/_logs.py +0 -0
  39. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_utils/_proxy.py +0 -0
  40. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_utils/_reflection.py +0 -0
  41. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_utils/_streams.py +0 -0
  42. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_utils/_sync.py +0 -0
  43. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/_utils/_utils.py +0 -0
  44. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/lib/.keep +0 -0
  45. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/py.typed +0 -0
  46. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/resources/__init__.py +0 -0
  47. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/resources/classifications/__init__.py +0 -0
  48. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/resources/classifications/classifications.py +0 -0
  49. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/resources/classifications/universal.py +0 -0
  50. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/resources/rerankings.py +0 -0
  51. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/types/__init__.py +0 -0
  52. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/types/classifications/__init__.py +0 -0
  53. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/types/classifications/universal_classification.py +0 -0
  54. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/types/classifications/universal_create_params.py +0 -0
  55. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/types/reranking.py +0 -0
  56. {isaacus-0.3.2 → isaacus-0.3.3}/src/isaacus/types/reranking_create_params.py +0 -0
  57. {isaacus-0.3.2 → isaacus-0.3.3}/tests/__init__.py +0 -0
  58. {isaacus-0.3.2 → isaacus-0.3.3}/tests/api_resources/__init__.py +0 -0
  59. {isaacus-0.3.2 → isaacus-0.3.3}/tests/api_resources/classifications/__init__.py +0 -0
  60. {isaacus-0.3.2 → isaacus-0.3.3}/tests/api_resources/classifications/test_universal.py +0 -0
  61. {isaacus-0.3.2 → isaacus-0.3.3}/tests/api_resources/test_rerankings.py +0 -0
  62. {isaacus-0.3.2 → isaacus-0.3.3}/tests/conftest.py +0 -0
  63. {isaacus-0.3.2 → isaacus-0.3.3}/tests/sample_file.txt +0 -0
  64. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_client.py +0 -0
  65. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_deepcopy.py +0 -0
  66. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_extract_files.py +0 -0
  67. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_files.py +0 -0
  68. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_models.py +0 -0
  69. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_qs.py +0 -0
  70. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_required_args.py +0 -0
  71. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_response.py +0 -0
  72. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_streaming.py +0 -0
  73. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_utils/test_proxy.py +0 -0
  74. {isaacus-0.3.2 → isaacus-0.3.3}/tests/test_utils/test_typing.py +0 -0
  75. {isaacus-0.3.2 → isaacus-0.3.3}/tests/utils.py +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.3.3"
3
+ }
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.3 (2025-04-16)
4
+
5
+ Full Changelog: [v0.3.2...v0.3.3](https://github.com/isaacus-dev/isaacus-python/compare/v0.3.2...v0.3.3)
6
+
7
+ ### Bug Fixes
8
+
9
+ * **perf:** optimize some hot paths ([eee757b](https://github.com/isaacus-dev/isaacus-python/commit/eee757ba44a895fcf2052b9981783b6cf233653f))
10
+ * **perf:** skip traversing types for NotGiven values ([7705a99](https://github.com/isaacus-dev/isaacus-python/commit/7705a99e0efd9724eb3260550b4b58081af85878))
11
+
12
+
13
+ ### Chores
14
+
15
+ * **client:** minor internal fixes ([a8dad58](https://github.com/isaacus-dev/isaacus-python/commit/a8dad5881d0f3f5d1929574efba483a8fcdbc322))
16
+ * **internal:** codegen related update ([93cdfa0](https://github.com/isaacus-dev/isaacus-python/commit/93cdfa0c0dfc947ec76f10291887b90324301b32))
17
+ * **internal:** expand CI branch coverage ([cc5df77](https://github.com/isaacus-dev/isaacus-python/commit/cc5df7771a9ea699b0e37533070e1cb5569d7ad9))
18
+ * **internal:** reduce CI branch coverage ([2cb8fb8](https://github.com/isaacus-dev/isaacus-python/commit/2cb8fb81f4cea76d12ae3feeb09e4b43b743e8c4))
19
+ * **internal:** slight transform perf improvement ([6f47eaf](https://github.com/isaacus-dev/isaacus-python/commit/6f47eafa0ebcd31741f24bea539a4c54e88a758e))
20
+ * **internal:** update pyright settings ([7dd9ad4](https://github.com/isaacus-dev/isaacus-python/commit/7dd9ad4a4a25825929a4916168a07d74bcc52fbe))
21
+
22
+
23
+ ### Documentation
24
+
25
+ * **api:** removed description of certain objects due to Mintlify bug ([9099926](https://github.com/isaacus-dev/isaacus-python/commit/90999261a360fef3ba92c52e4ad5361b79b499e6))
26
+
3
27
  ## 0.3.2 (2025-04-04)
4
28
 
5
29
  Full Changelog: [v0.3.1...v0.3.2](https://github.com/isaacus-dev/isaacus-python/compare/v0.3.1...v0.3.2)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: isaacus
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: The official Python library for the isaacus API
5
5
  Project-URL: Homepage, https://github.com/isaacus-dev/isaacus-python
6
6
  Project-URL: Repository, https://github.com/isaacus-dev/isaacus-python
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "isaacus"
3
- version = "0.3.2"
3
+ version = "0.3.3"
4
4
  description = "The official Python library for the isaacus API"
5
5
  dynamic = ["readme"]
6
6
  license = "Apache-2.0"
@@ -147,6 +147,7 @@ exclude = [
147
147
  ]
148
148
 
149
149
  reportImplicitOverride = true
150
+ reportOverlappingOverload = false
150
151
 
151
152
  reportImportCycles = false
152
153
  reportPrivateUsage = false
@@ -409,7 +409,8 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
409
409
 
410
410
  idempotency_header = self._idempotency_header
411
411
  if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers:
412
- headers[idempotency_header] = options.idempotency_key or self._idempotency_key()
412
+ options.idempotency_key = options.idempotency_key or self._idempotency_key()
413
+ headers[idempotency_header] = options.idempotency_key
413
414
 
414
415
  # Don't set these headers if they were already set or removed by the caller. We check
415
416
  # `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
@@ -943,6 +944,10 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
943
944
  request = self._build_request(options, retries_taken=retries_taken)
944
945
  self._prepare_request(request)
945
946
 
947
+ if options.idempotency_key:
948
+ # ensure the idempotency key is reused between requests
949
+ input_options.idempotency_key = options.idempotency_key
950
+
946
951
  kwargs: HttpxSendArgs = {}
947
952
  if self.custom_auth is not None:
948
953
  kwargs["auth"] = self.custom_auth
@@ -1475,6 +1480,10 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1475
1480
  request = self._build_request(options, retries_taken=retries_taken)
1476
1481
  await self._prepare_request(request)
1477
1482
 
1483
+ if options.idempotency_key:
1484
+ # ensure the idempotency key is reused between requests
1485
+ input_options.idempotency_key = options.idempotency_key
1486
+
1478
1487
  kwargs: HttpxSendArgs = {}
1479
1488
  if self.custom_auth is not None:
1480
1489
  kwargs["auth"] = self.custom_auth
@@ -5,13 +5,15 @@ import base64
5
5
  import pathlib
6
6
  from typing import Any, Mapping, TypeVar, cast
7
7
  from datetime import date, datetime
8
- from typing_extensions import Literal, get_args, override, get_type_hints
8
+ from typing_extensions import Literal, get_args, override, get_type_hints as _get_type_hints
9
9
 
10
10
  import anyio
11
11
  import pydantic
12
12
 
13
13
  from ._utils import (
14
14
  is_list,
15
+ is_given,
16
+ lru_cache,
15
17
  is_mapping,
16
18
  is_iterable,
17
19
  )
@@ -108,6 +110,7 @@ def transform(
108
110
  return cast(_T, transformed)
109
111
 
110
112
 
113
+ @lru_cache(maxsize=8096)
111
114
  def _get_annotated_type(type_: type) -> type | None:
112
115
  """If the given type is an `Annotated` type then it is returned, if not `None` is returned.
113
116
 
@@ -142,6 +145,10 @@ def _maybe_transform_key(key: str, type_: type) -> str:
142
145
  return key
143
146
 
144
147
 
148
+ def _no_transform_needed(annotation: type) -> bool:
149
+ return annotation == float or annotation == int
150
+
151
+
145
152
  def _transform_recursive(
146
153
  data: object,
147
154
  *,
@@ -184,6 +191,15 @@ def _transform_recursive(
184
191
  return cast(object, data)
185
192
 
186
193
  inner_type = extract_type_arg(stripped_type, 0)
194
+ if _no_transform_needed(inner_type):
195
+ # for some types there is no need to transform anything, so we can get a small
196
+ # perf boost from skipping that work.
197
+ #
198
+ # but we still need to convert to a list to ensure the data is json-serializable
199
+ if is_list(data):
200
+ return data
201
+ return list(data)
202
+
187
203
  return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
188
204
 
189
205
  if is_union_type(stripped_type):
@@ -245,6 +261,11 @@ def _transform_typeddict(
245
261
  result: dict[str, object] = {}
246
262
  annotations = get_type_hints(expected_type, include_extras=True)
247
263
  for key, value in data.items():
264
+ if not is_given(value):
265
+ # we don't need to include `NotGiven` values here as they'll
266
+ # be stripped out before the request is sent anyway
267
+ continue
268
+
248
269
  type_ = annotations.get(key)
249
270
  if type_ is None:
250
271
  # we do not have a type annotation for this field, leave it as is
@@ -332,6 +353,15 @@ async def _async_transform_recursive(
332
353
  return cast(object, data)
333
354
 
334
355
  inner_type = extract_type_arg(stripped_type, 0)
356
+ if _no_transform_needed(inner_type):
357
+ # for some types there is no need to transform anything, so we can get a small
358
+ # perf boost from skipping that work.
359
+ #
360
+ # but we still need to convert to a list to ensure the data is json-serializable
361
+ if is_list(data):
362
+ return data
363
+ return list(data)
364
+
335
365
  return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
336
366
 
337
367
  if is_union_type(stripped_type):
@@ -393,6 +423,11 @@ async def _async_transform_typeddict(
393
423
  result: dict[str, object] = {}
394
424
  annotations = get_type_hints(expected_type, include_extras=True)
395
425
  for key, value in data.items():
426
+ if not is_given(value):
427
+ # we don't need to include `NotGiven` values here as they'll
428
+ # be stripped out before the request is sent anyway
429
+ continue
430
+
396
431
  type_ = annotations.get(key)
397
432
  if type_ is None:
398
433
  # we do not have a type annotation for this field, leave it as is
@@ -400,3 +435,13 @@ async def _async_transform_typeddict(
400
435
  else:
401
436
  result[_maybe_transform_key(key, type_)] = await _async_transform_recursive(value, annotation=type_)
402
437
  return result
438
+
439
+
440
+ @lru_cache(maxsize=8096)
441
+ def get_type_hints(
442
+ obj: Any,
443
+ globalns: dict[str, Any] | None = None,
444
+ localns: Mapping[str, Any] | None = None,
445
+ include_extras: bool = False,
446
+ ) -> dict[str, Any]:
447
+ return _get_type_hints(obj, globalns=globalns, localns=localns, include_extras=include_extras)
@@ -13,6 +13,7 @@ from typing_extensions import (
13
13
  get_origin,
14
14
  )
15
15
 
16
+ from ._utils import lru_cache
16
17
  from .._types import InheritsGeneric
17
18
  from .._compat import is_union as _is_union
18
19
 
@@ -66,6 +67,7 @@ def is_type_alias_type(tp: Any, /) -> TypeIs[typing_extensions.TypeAliasType]:
66
67
 
67
68
 
68
69
  # Extracts T from Annotated[T, ...] or from Required[Annotated[T, ...]]
70
+ @lru_cache(maxsize=8096)
69
71
  def strip_annotated_type(typ: type) -> type:
70
72
  if is_required_type(typ) or is_annotated_type(typ):
71
73
  return strip_annotated_type(cast(type, get_args(typ)[0]))
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "isaacus"
4
- __version__ = "0.3.2" # x-release-please-version
4
+ __version__ = "0.3.3" # x-release-please-version
@@ -8,7 +8,7 @@ from typing_extensions import Required, Annotated, TypedDict
8
8
 
9
9
  import pytest
10
10
 
11
- from isaacus._types import Base64FileInput
11
+ from isaacus._types import NOT_GIVEN, Base64FileInput
12
12
  from isaacus._utils import (
13
13
  PropertyInfo,
14
14
  transform as _transform,
@@ -432,3 +432,22 @@ async def test_base64_file_input(use_async: bool) -> None:
432
432
  assert await transform({"foo": io.BytesIO(b"Hello, world!")}, TypedDictBase64Input, use_async) == {
433
433
  "foo": "SGVsbG8sIHdvcmxkIQ=="
434
434
  } # type: ignore[comparison-overlap]
435
+
436
+
437
+ @parametrize
438
+ @pytest.mark.asyncio
439
+ async def test_transform_skipping(use_async: bool) -> None:
440
+ # lists of ints are left as-is
441
+ data = [1, 2, 3]
442
+ assert await transform(data, List[int], use_async) is data
443
+
444
+ # iterables of ints are converted to a list
445
+ data = iter([1, 2, 3])
446
+ assert await transform(data, Iterable[int], use_async) == [1, 2, 3]
447
+
448
+
449
+ @parametrize
450
+ @pytest.mark.asyncio
451
+ async def test_strips_notgiven(use_async: bool) -> None:
452
+ assert await transform({"foo_bar": "bar"}, Foo1, use_async) == {"fooBar": "bar"}
453
+ assert await transform({"foo_bar": NOT_GIVEN}, Foo1, use_async) == {}
@@ -1,3 +0,0 @@
1
- {
2
- ".": "0.3.2"
3
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes