Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.20.0"
".": "1.20.1"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
12 changes: 2 additions & 10 deletions src/finch/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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]:
Expand Down
22 changes: 22 additions & 0 deletions src/finch/_utils/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/finch/_version.py
Original file line number Diff line number Diff line change
@@ -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
24 changes: 12 additions & 12 deletions src/finch/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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]:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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]:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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]:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions tests/api_resources/hris/benefits/test_individuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions tests/api_resources/sandbox/connections/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down Expand Up @@ -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"])

Expand Down
12 changes: 12 additions & 0 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]