From 89df119f02f94e79d7fa75ba2a78b568624328bc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 4 Apr 2025 21:09:42 +0000 Subject: [PATCH 1/6] chore(internal): codegen related update (#641) --- src/finch/pagination.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/finch/pagination.py b/src/finch/pagination.py index 4ee0f60d..dedacd1c 100644 --- a/src/finch/pagination.py +++ b/src/finch/pagination.py @@ -123,7 +123,7 @@ def next_page_info(self) -> None: class SyncIndividualsPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]): individuals: List[_T] """The array of employees.""" - paging: Optional[Paging] = None + paging: Paging @override def _get_page_items(self) -> List[_T]: @@ -135,7 +135,7 @@ def _get_page_items(self) -> List[_T]: @override def next_page_info(self) -> Optional[PageInfo]: offset = None - if self.paging is not None: + if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.offset is not None: offset = self.paging.offset if offset is None: @@ -145,7 +145,7 @@ def next_page_info(self) -> Optional[PageInfo]: current_count = offset + length count = None - if self.paging is not None: + if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.count is not None: count = self.paging.count if count is None: @@ -160,7 +160,7 @@ def next_page_info(self) -> Optional[PageInfo]: class AsyncIndividualsPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): individuals: List[_T] """The array of employees.""" - paging: Optional[Paging] = None + paging: Paging @override def _get_page_items(self) -> List[_T]: @@ -172,7 +172,7 @@ def _get_page_items(self) -> List[_T]: @override def next_page_info(self) -> Optional[PageInfo]: offset = None - if self.paging is not None: + if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.offset is not None: offset = self.paging.offset if offset is None: @@ -182,7 +182,7 @@ def next_page_info(self) -> Optional[PageInfo]: current_count = offset + length count = None - if self.paging is not None: + if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.count is not None: count = self.paging.count if count is None: @@ -196,7 +196,7 @@ def next_page_info(self) -> Optional[PageInfo]: class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]): data: List[_T] - paging: Optional[Paging] = None + paging: Paging @override def _get_page_items(self) -> List[_T]: @@ -208,7 +208,7 @@ def _get_page_items(self) -> List[_T]: @override def next_page_info(self) -> Optional[PageInfo]: offset = None - if self.paging is not None: + if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.offset is not None: offset = self.paging.offset if offset is None: @@ -218,7 +218,7 @@ def next_page_info(self) -> Optional[PageInfo]: current_count = offset + length count = None - if self.paging is not None: + if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.count is not None: count = self.paging.count if count is None: @@ -232,7 +232,7 @@ def next_page_info(self) -> Optional[PageInfo]: class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]): data: List[_T] - paging: Optional[Paging] = None + paging: Paging @override def _get_page_items(self) -> List[_T]: @@ -244,7 +244,7 @@ def _get_page_items(self) -> List[_T]: @override def next_page_info(self) -> Optional[PageInfo]: offset = None - if self.paging is not None: + if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.offset is not None: offset = self.paging.offset if offset is None: @@ -254,7 +254,7 @@ def next_page_info(self) -> Optional[PageInfo]: current_count = offset + length count = None - if self.paging is not None: + if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.count is not None: count = self.paging.count if count is None: From b91fc64410c673f9a078eef8084743ea05cada0b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 12:35:23 +0000 Subject: [PATCH 2/6] fix(client): send all configured auth headers (#643) --- src/finch/_client.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/finch/_client.py b/src/finch/_client.py index e98dadf2..f5ef2acb 100644 --- a/src/finch/_client.py +++ b/src/finch/_client.py @@ -147,11 +147,7 @@ def qs(self) -> Querystring: @property @override def auth_headers(self) -> dict[str, str]: - if self._bearer_auth: - return self._bearer_auth - if self._basic_auth: - return self._basic_auth - return {} + return {**self._bearer_auth, **self._basic_auth} @property def _bearer_auth(self) -> dict[str, str]: @@ -455,11 +451,7 @@ def qs(self) -> Querystring: @property @override def auth_headers(self) -> dict[str, str]: - if self._bearer_auth: - return self._bearer_auth - if self._basic_auth: - return self._basic_auth - return {} + return {**self._bearer_auth, **self._basic_auth} @property def _bearer_auth(self) -> dict[str, str]: From 830bfa128df0796cf5c040b0a46dbac4c5cfd433 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 04:32:50 +0000 Subject: [PATCH 3/6] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 05cd9fbf..a45a587e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 46 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-14d375aab89e6b212fe459805a42d6ea7d7da8eae2037ae710a187d06911be1d.yml openapi_spec_hash: 08b86ecbec3323717d48e4aaee48ed54 -config_hash: 2bca9e6b32f742acb077cf8822ec9e23 +config_hash: ce10384813f68ba3fed61c7b601b396b From e6e04cc0dfce27441214d1f0781cec1b56c0243b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 12:09:03 +0000 Subject: [PATCH 4/6] chore(internal): slight transform perf improvement (#644) --- src/finch/_utils/_transform.py | 22 ++++++++++++++++++++++ tests/test_transform.py | 12 ++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/finch/_utils/_transform.py b/src/finch/_utils/_transform.py index 7ac2e17f..3ec62081 100644 --- a/src/finch/_utils/_transform.py +++ b/src/finch/_utils/_transform.py @@ -142,6 +142,10 @@ def _maybe_transform_key(key: str, type_: type) -> str: return key +def _no_transform_needed(annotation: type) -> bool: + return annotation == float or annotation == int + + def _transform_recursive( data: object, *, @@ -184,6 +188,15 @@ def _transform_recursive( return cast(object, data) inner_type = extract_type_arg(stripped_type, 0) + if _no_transform_needed(inner_type): + # for some types there is no need to transform anything, so we can get a small + # perf boost from skipping that work. + # + # but we still need to convert to a list to ensure the data is json-serializable + if is_list(data): + return data + return list(data) + return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data] if is_union_type(stripped_type): @@ -332,6 +345,15 @@ async def _async_transform_recursive( return cast(object, data) inner_type = extract_type_arg(stripped_type, 0) + if _no_transform_needed(inner_type): + # for some types there is no need to transform anything, so we can get a small + # perf boost from skipping that work. + # + # but we still need to convert to a list to ensure the data is json-serializable + if is_list(data): + return data + return list(data) + return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data] if is_union_type(stripped_type): diff --git a/tests/test_transform.py b/tests/test_transform.py index ad65c434..80271b12 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -432,3 +432,15 @@ async def test_base64_file_input(use_async: bool) -> None: assert await transform({"foo": io.BytesIO(b"Hello, world!")}, TypedDictBase64Input, use_async) == { "foo": "SGVsbG8sIHdvcmxkIQ==" } # type: ignore[comparison-overlap] + + +@parametrize +@pytest.mark.asyncio +async def test_transform_skipping(use_async: bool) -> None: + # lists of ints are left as-is + data = [1, 2, 3] + assert await transform(data, List[int], use_async) is data + + # iterables of ints are converted to a list + data = iter([1, 2, 3]) + assert await transform(data, Iterable[int], use_async) == [1, 2, 3] From 8e81d760fc7761ef583d3407eaa9640d6301ea8c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:23:16 +0000 Subject: [PATCH 5/6] chore(tests): improve enum examples (#645) --- tests/api_resources/hris/benefits/test_individuals.py | 8 ++++---- tests/api_resources/sandbox/connections/test_accounts.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/api_resources/hris/benefits/test_individuals.py b/tests/api_resources/hris/benefits/test_individuals.py index afc8a2e3..d8677fa1 100644 --- a/tests/api_resources/hris/benefits/test_individuals.py +++ b/tests/api_resources/hris/benefits/test_individuals.py @@ -43,12 +43,12 @@ def test_method_enroll_many_with_all_params(self, client: Finch) -> None: "catch_up": False, "company_contribution": { "amount": 400, - "type": "fixed", + "type": "percent", }, "effective_date": parse_date("2025-01-01"), "employee_deduction": { "amount": 1000, - "type": "fixed", + "type": "percent", }, }, "individual_id": "d02a6346-1f08-4312-a064-49ff3cafaa7a", @@ -241,12 +241,12 @@ async def test_method_enroll_many_with_all_params(self, async_client: AsyncFinch "catch_up": False, "company_contribution": { "amount": 400, - "type": "fixed", + "type": "percent", }, "effective_date": parse_date("2025-01-01"), "employee_deduction": { "amount": 1000, - "type": "fixed", + "type": "percent", }, }, "individual_id": "d02a6346-1f08-4312-a064-49ff3cafaa7a", diff --git a/tests/api_resources/sandbox/connections/test_accounts.py b/tests/api_resources/sandbox/connections/test_accounts.py index 561aa3ba..5ff83d69 100644 --- a/tests/api_resources/sandbox/connections/test_accounts.py +++ b/tests/api_resources/sandbox/connections/test_accounts.py @@ -72,7 +72,7 @@ def test_method_update(self, client: Finch) -> None: @parametrize def test_method_update_with_all_params(self, client: Finch) -> None: account = client.sandbox.connections.accounts.update( - connection_status="pending", + connection_status="reauth", ) assert_matches_type(AccountUpdateResponse, account, path=["response"]) @@ -152,7 +152,7 @@ async def test_method_update(self, async_client: AsyncFinch) -> None: @parametrize async def test_method_update_with_all_params(self, async_client: AsyncFinch) -> None: account = await async_client.sandbox.connections.accounts.update( - connection_status="pending", + connection_status="reauth", ) assert_matches_type(AccountUpdateResponse, account, path=["response"]) From 8b77bbf4c8410232e0eb6fbf55dd07c31e483ad5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:23:55 +0000 Subject: [PATCH 6/6] release: 1.20.1 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 15 +++++++++++++++ pyproject.toml | 2 +- src/finch/_version.py | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 69eb19a7..511722b9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.20.0" + ".": "1.20.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 87585870..356b6ee9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 1.20.1 (2025-04-08) + +Full Changelog: [v1.20.0...v1.20.1](https://github.com/Finch-API/finch-api-python/compare/v1.20.0...v1.20.1) + +### Bug Fixes + +* **client:** send all configured auth headers ([#643](https://github.com/Finch-API/finch-api-python/issues/643)) ([b91fc64](https://github.com/Finch-API/finch-api-python/commit/b91fc64410c673f9a078eef8084743ea05cada0b)) + + +### Chores + +* **internal:** codegen related update ([#641](https://github.com/Finch-API/finch-api-python/issues/641)) ([89df119](https://github.com/Finch-API/finch-api-python/commit/89df119f02f94e79d7fa75ba2a78b568624328bc)) +* **internal:** slight transform perf improvement ([#644](https://github.com/Finch-API/finch-api-python/issues/644)) ([e6e04cc](https://github.com/Finch-API/finch-api-python/commit/e6e04cc0dfce27441214d1f0781cec1b56c0243b)) +* **tests:** improve enum examples ([#645](https://github.com/Finch-API/finch-api-python/issues/645)) ([8e81d76](https://github.com/Finch-API/finch-api-python/commit/8e81d760fc7761ef583d3407eaa9640d6301ea8c)) + ## 1.20.0 (2025-04-04) Full Changelog: [v1.19.0...v1.20.0](https://github.com/Finch-API/finch-api-python/compare/v1.19.0...v1.20.0) diff --git a/pyproject.toml b/pyproject.toml index e2f0bd79..7506addc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "finch-api" -version = "1.20.0" +version = "1.20.1" description = "The official Python library for the Finch API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/finch/_version.py b/src/finch/_version.py index c1c10a09..15f2237e 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__ = "1.20.0" # x-release-please-version +__version__ = "1.20.1" # x-release-please-version