Skip to content

Commit c4b8703

Browse files
release: 1.20.1 (#642)
* chore(internal): codegen related update (#641) * fix(client): send all configured auth headers (#643) * codegen metadata * chore(internal): slight transform perf improvement (#644) * chore(tests): improve enum examples (#645) * release: 1.20.1 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent cc9ebd6 commit c4b8703

File tree

11 files changed

+73
-32
lines changed

11 files changed

+73
-32
lines changed

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.20.0"
2+
".": "1.20.1"
33
}

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 46
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-14d375aab89e6b212fe459805a42d6ea7d7da8eae2037ae710a187d06911be1d.yml
33
openapi_spec_hash: 08b86ecbec3323717d48e4aaee48ed54
4-
config_hash: 2bca9e6b32f742acb077cf8822ec9e23
4+
config_hash: ce10384813f68ba3fed61c7b601b396b

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## 1.20.1 (2025-04-08)
4+
5+
Full Changelog: [v1.20.0...v1.20.1](https://github.com/Finch-API/finch-api-python/compare/v1.20.0...v1.20.1)
6+
7+
### Bug Fixes
8+
9+
* **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))
10+
11+
12+
### Chores
13+
14+
* **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))
15+
* **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))
16+
* **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))
17+
318
## 1.20.0 (2025-04-04)
419

520
Full Changelog: [v1.19.0...v1.20.0](https://github.com/Finch-API/finch-api-python/compare/v1.19.0...v1.20.0)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "finch-api"
3-
version = "1.20.0"
3+
version = "1.20.1"
44
description = "The official Python library for the Finch API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/finch/_client.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,7 @@ def qs(self) -> Querystring:
147147
@property
148148
@override
149149
def auth_headers(self) -> dict[str, str]:
150-
if self._bearer_auth:
151-
return self._bearer_auth
152-
if self._basic_auth:
153-
return self._basic_auth
154-
return {}
150+
return {**self._bearer_auth, **self._basic_auth}
155151

156152
@property
157153
def _bearer_auth(self) -> dict[str, str]:
@@ -455,11 +451,7 @@ def qs(self) -> Querystring:
455451
@property
456452
@override
457453
def auth_headers(self) -> dict[str, str]:
458-
if self._bearer_auth:
459-
return self._bearer_auth
460-
if self._basic_auth:
461-
return self._basic_auth
462-
return {}
454+
return {**self._bearer_auth, **self._basic_auth}
463455

464456
@property
465457
def _bearer_auth(self) -> dict[str, str]:

src/finch/_utils/_transform.py

+22
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ def _maybe_transform_key(key: str, type_: type) -> str:
142142
return key
143143

144144

145+
def _no_transform_needed(annotation: type) -> bool:
146+
return annotation == float or annotation == int
147+
148+
145149
def _transform_recursive(
146150
data: object,
147151
*,
@@ -184,6 +188,15 @@ def _transform_recursive(
184188
return cast(object, data)
185189

186190
inner_type = extract_type_arg(stripped_type, 0)
191+
if _no_transform_needed(inner_type):
192+
# for some types there is no need to transform anything, so we can get a small
193+
# perf boost from skipping that work.
194+
#
195+
# but we still need to convert to a list to ensure the data is json-serializable
196+
if is_list(data):
197+
return data
198+
return list(data)
199+
187200
return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
188201

189202
if is_union_type(stripped_type):
@@ -332,6 +345,15 @@ async def _async_transform_recursive(
332345
return cast(object, data)
333346

334347
inner_type = extract_type_arg(stripped_type, 0)
348+
if _no_transform_needed(inner_type):
349+
# for some types there is no need to transform anything, so we can get a small
350+
# perf boost from skipping that work.
351+
#
352+
# but we still need to convert to a list to ensure the data is json-serializable
353+
if is_list(data):
354+
return data
355+
return list(data)
356+
335357
return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
336358

337359
if is_union_type(stripped_type):

src/finch/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "finch"
4-
__version__ = "1.20.0" # x-release-please-version
4+
__version__ = "1.20.1" # x-release-please-version

src/finch/pagination.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def next_page_info(self) -> None:
123123
class SyncIndividualsPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
124124
individuals: List[_T]
125125
"""The array of employees."""
126-
paging: Optional[Paging] = None
126+
paging: Paging
127127

128128
@override
129129
def _get_page_items(self) -> List[_T]:
@@ -135,7 +135,7 @@ def _get_page_items(self) -> List[_T]:
135135
@override
136136
def next_page_info(self) -> Optional[PageInfo]:
137137
offset = None
138-
if self.paging is not None:
138+
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
139139
if self.paging.offset is not None:
140140
offset = self.paging.offset
141141
if offset is None:
@@ -145,7 +145,7 @@ def next_page_info(self) -> Optional[PageInfo]:
145145
current_count = offset + length
146146

147147
count = None
148-
if self.paging is not None:
148+
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
149149
if self.paging.count is not None:
150150
count = self.paging.count
151151
if count is None:
@@ -160,7 +160,7 @@ def next_page_info(self) -> Optional[PageInfo]:
160160
class AsyncIndividualsPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
161161
individuals: List[_T]
162162
"""The array of employees."""
163-
paging: Optional[Paging] = None
163+
paging: Paging
164164

165165
@override
166166
def _get_page_items(self) -> List[_T]:
@@ -172,7 +172,7 @@ def _get_page_items(self) -> List[_T]:
172172
@override
173173
def next_page_info(self) -> Optional[PageInfo]:
174174
offset = None
175-
if self.paging is not None:
175+
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
176176
if self.paging.offset is not None:
177177
offset = self.paging.offset
178178
if offset is None:
@@ -182,7 +182,7 @@ def next_page_info(self) -> Optional[PageInfo]:
182182
current_count = offset + length
183183

184184
count = None
185-
if self.paging is not None:
185+
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
186186
if self.paging.count is not None:
187187
count = self.paging.count
188188
if count is None:
@@ -196,7 +196,7 @@ def next_page_info(self) -> Optional[PageInfo]:
196196

197197
class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
198198
data: List[_T]
199-
paging: Optional[Paging] = None
199+
paging: Paging
200200

201201
@override
202202
def _get_page_items(self) -> List[_T]:
@@ -208,7 +208,7 @@ def _get_page_items(self) -> List[_T]:
208208
@override
209209
def next_page_info(self) -> Optional[PageInfo]:
210210
offset = None
211-
if self.paging is not None:
211+
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
212212
if self.paging.offset is not None:
213213
offset = self.paging.offset
214214
if offset is None:
@@ -218,7 +218,7 @@ def next_page_info(self) -> Optional[PageInfo]:
218218
current_count = offset + length
219219

220220
count = None
221-
if self.paging is not None:
221+
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
222222
if self.paging.count is not None:
223223
count = self.paging.count
224224
if count is None:
@@ -232,7 +232,7 @@ def next_page_info(self) -> Optional[PageInfo]:
232232

233233
class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
234234
data: List[_T]
235-
paging: Optional[Paging] = None
235+
paging: Paging
236236

237237
@override
238238
def _get_page_items(self) -> List[_T]:
@@ -244,7 +244,7 @@ def _get_page_items(self) -> List[_T]:
244244
@override
245245
def next_page_info(self) -> Optional[PageInfo]:
246246
offset = None
247-
if self.paging is not None:
247+
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
248248
if self.paging.offset is not None:
249249
offset = self.paging.offset
250250
if offset is None:
@@ -254,7 +254,7 @@ def next_page_info(self) -> Optional[PageInfo]:
254254
current_count = offset + length
255255

256256
count = None
257-
if self.paging is not None:
257+
if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison]
258258
if self.paging.count is not None:
259259
count = self.paging.count
260260
if count is None:

tests/api_resources/hris/benefits/test_individuals.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ def test_method_enroll_many_with_all_params(self, client: Finch) -> None:
4343
"catch_up": False,
4444
"company_contribution": {
4545
"amount": 400,
46-
"type": "fixed",
46+
"type": "percent",
4747
},
4848
"effective_date": parse_date("2025-01-01"),
4949
"employee_deduction": {
5050
"amount": 1000,
51-
"type": "fixed",
51+
"type": "percent",
5252
},
5353
},
5454
"individual_id": "d02a6346-1f08-4312-a064-49ff3cafaa7a",
@@ -241,12 +241,12 @@ async def test_method_enroll_many_with_all_params(self, async_client: AsyncFinch
241241
"catch_up": False,
242242
"company_contribution": {
243243
"amount": 400,
244-
"type": "fixed",
244+
"type": "percent",
245245
},
246246
"effective_date": parse_date("2025-01-01"),
247247
"employee_deduction": {
248248
"amount": 1000,
249-
"type": "fixed",
249+
"type": "percent",
250250
},
251251
},
252252
"individual_id": "d02a6346-1f08-4312-a064-49ff3cafaa7a",

tests/api_resources/sandbox/connections/test_accounts.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_method_update(self, client: Finch) -> None:
7272
@parametrize
7373
def test_method_update_with_all_params(self, client: Finch) -> None:
7474
account = client.sandbox.connections.accounts.update(
75-
connection_status="pending",
75+
connection_status="reauth",
7676
)
7777
assert_matches_type(AccountUpdateResponse, account, path=["response"])
7878

@@ -152,7 +152,7 @@ async def test_method_update(self, async_client: AsyncFinch) -> None:
152152
@parametrize
153153
async def test_method_update_with_all_params(self, async_client: AsyncFinch) -> None:
154154
account = await async_client.sandbox.connections.accounts.update(
155-
connection_status="pending",
155+
connection_status="reauth",
156156
)
157157
assert_matches_type(AccountUpdateResponse, account, path=["response"])
158158

tests/test_transform.py

+12
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,15 @@ async def test_base64_file_input(use_async: bool) -> None:
432432
assert await transform({"foo": io.BytesIO(b"Hello, world!")}, TypedDictBase64Input, use_async) == {
433433
"foo": "SGVsbG8sIHdvcmxkIQ=="
434434
} # 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]

0 commit comments

Comments
 (0)