diff --git a/.release-please-manifest.json b/.release-please-manifest.json index af99186b..eae5bf18 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.21.8" + ".": "0.21.9" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index a51a0a96..45f042b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.21.9 (2024-07-10) + +Full Changelog: [v0.21.8...v0.21.9](https://github.com/Finch-API/finch-api-python/compare/v0.21.8...v0.21.9) + +### Chores + +* **internal:** add helper function ([#424](https://github.com/Finch-API/finch-api-python/issues/424)) ([a9a6206](https://github.com/Finch-API/finch-api-python/commit/a9a6206a74181a3d04fad5bcadf872c88ac4d13a)) +* **internal:** minor request options handling changes ([#422](https://github.com/Finch-API/finch-api-python/issues/422)) ([ed15e98](https://github.com/Finch-API/finch-api-python/commit/ed15e9847c8f2d5388526aa89847f5bed646e7bc)) + ## 0.21.8 (2024-07-03) Full Changelog: [v0.21.7...v0.21.8](https://github.com/Finch-API/finch-api-python/compare/v0.21.7...v0.21.8) diff --git a/pyproject.toml b/pyproject.toml index cfb93ba4..67664828 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "finch-api" -version = "0.21.8" +version = "0.21.9" description = "The official Python library for the Finch API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/finch/_base_client.py b/src/finch/_base_client.py index accdccdc..2f20def3 100644 --- a/src/finch/_base_client.py +++ b/src/finch/_base_client.py @@ -956,6 +956,11 @@ def _request( stream: bool, stream_cls: type[_StreamT] | None, ) -> ResponseT | _StreamT: + # create a copy of the options we were given so that if the + # options are mutated later & we then retry, the retries are + # given the original options + input_options = model_copy(options) + cast_to = self._maybe_override_cast_to(cast_to, options) self._prepare_options(options) @@ -980,7 +985,7 @@ def _request( if retries > 0: return self._retry_request( - options, + input_options, cast_to, retries, stream=stream, @@ -995,7 +1000,7 @@ def _request( if retries > 0: return self._retry_request( - options, + input_options, cast_to, retries, stream=stream, @@ -1023,7 +1028,7 @@ def _request( if retries > 0 and self._should_retry(err.response): err.response.close() return self._retry_request( - options, + input_options, cast_to, retries, err.response.headers, @@ -1532,6 +1537,11 @@ async def _request( # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() + # create a copy of the options we were given so that if the + # options are mutated later & we then retry, the retries are + # given the original options + input_options = model_copy(options) + cast_to = self._maybe_override_cast_to(cast_to, options) await self._prepare_options(options) @@ -1554,7 +1564,7 @@ async def _request( if retries > 0: return await self._retry_request( - options, + input_options, cast_to, retries, stream=stream, @@ -1569,7 +1579,7 @@ async def _request( if retries > 0: return await self._retry_request( - options, + input_options, cast_to, retries, stream=stream, @@ -1592,7 +1602,7 @@ async def _request( if retries > 0 and self._should_retry(err.response): await err.response.aclose() return await self._retry_request( - options, + input_options, cast_to, retries, err.response.headers, diff --git a/src/finch/_models.py b/src/finch/_models.py index 5d95bb4b..eb7ce3bd 100644 --- a/src/finch/_models.py +++ b/src/finch/_models.py @@ -643,6 +643,14 @@ def validate_type(*, type_: type[_T], value: object) -> _T: return cast(_T, _validate_non_model_type(type_=type_, value=value)) +def set_pydantic_config(typ: Any, config: pydantic.ConfigDict) -> None: + """Add a pydantic config for the given type. + + Note: this is a no-op on Pydantic v1. + """ + setattr(typ, "__pydantic_config__", config) # noqa: B010 + + # our use of subclasssing here causes weirdness for type checkers, # so we just pretend that we don't subclass if TYPE_CHECKING: diff --git a/src/finch/_version.py b/src/finch/_version.py index 7ab7e270..85c31c18 100644 --- a/src/finch/_version.py +++ b/src/finch/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "finch" -__version__ = "0.21.8" # x-release-please-version +__version__ = "0.21.9" # x-release-please-version