Skip to content

Commit 9028659

Browse files
release: 1.31.0 (#667)
* feat(api): api update * codegen metadata * codegen metadata * codegen metadata * fix(parsing): ignore empty metadata * fix(parsing): parse extra field types * feat(api): api update * chore(project): add settings file for vscode * release: 1.31.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent 879cf19 commit 9028659

17 files changed

+136
-45
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.prism.log
2-
.vscode
32
_dev
43

54
__pycache__

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.30.3"
2+
".": "1.31.0"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 46
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-f7e741bc6e0175fd96a9db5348092b90a77b0985154c0814bb681ad5dccdf19a.yml
3-
openapi_spec_hash: b348a9ef407a8e91dd770fcb219d4ac5
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-73c284d36c1ed2d9963fc733e421005fad76e559de8efe9baa6511a43dd72668.yml
3+
openapi_spec_hash: 1e58c4445919b71c77e5c7f16bd6fa7d
44
config_hash: 5146b12344dae76238940989dac1e8a0

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.analysis.importFormat": "relative",
3+
}

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## 1.31.0 (2025-07-24)
4+
5+
Full Changelog: [v1.30.3...v1.31.0](https://github.com/Finch-API/finch-api-python/compare/v1.30.3...v1.31.0)
6+
7+
### Features
8+
9+
* **api:** api update ([1dd1ffa](https://github.com/Finch-API/finch-api-python/commit/1dd1fface4ca9b49a92bc319b233b7689f23b006))
10+
* **api:** api update ([d0c7fd2](https://github.com/Finch-API/finch-api-python/commit/d0c7fd2ada777eba81f483ce11340c01aca1abe0))
11+
12+
13+
### Bug Fixes
14+
15+
* **parsing:** ignore empty metadata ([acaec4b](https://github.com/Finch-API/finch-api-python/commit/acaec4b1fffcb4323e950cb393707724f2fa7e62))
16+
* **parsing:** parse extra field types ([d14c906](https://github.com/Finch-API/finch-api-python/commit/d14c9060175c9a1e345f5507a9634c6d81683395))
17+
18+
19+
### Chores
20+
21+
* **project:** add settings file for vscode ([a2c4c2a](https://github.com/Finch-API/finch-api-python/commit/a2c4c2a8d81e8086dd8c8962806415f087b132c5))
22+
323
## 1.30.3 (2025-07-11)
424

525
Full Changelog: [v1.30.2...v1.30.3](https://github.com/Finch-API/finch-api-python/compare/v1.30.2...v1.30.3)

pyproject.toml

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

src/finch/_models.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,18 @@ def construct( # pyright: ignore[reportIncompatibleMethodOverride]
208208
else:
209209
fields_values[name] = field_get_default(field)
210210

211+
extra_field_type = _get_extra_fields_type(__cls)
212+
211213
_extra = {}
212214
for key, value in values.items():
213215
if key not in model_fields:
216+
parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value
217+
214218
if PYDANTIC_V2:
215-
_extra[key] = value
219+
_extra[key] = parsed
216220
else:
217221
_fields_set.add(key)
218-
fields_values[key] = value
222+
fields_values[key] = parsed
219223

220224
object.__setattr__(m, "__dict__", fields_values)
221225

@@ -370,6 +374,23 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
370374
return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
371375

372376

377+
def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:
378+
if not PYDANTIC_V2:
379+
# TODO
380+
return None
381+
382+
schema = cls.__pydantic_core_schema__
383+
if schema["type"] == "model":
384+
fields = schema["schema"]
385+
if fields["type"] == "model-fields":
386+
extras = fields.get("extras_schema")
387+
if extras and "cls" in extras:
388+
# mypy can't narrow the type
389+
return extras["cls"] # type: ignore[no-any-return]
390+
391+
return None
392+
393+
373394
def is_basemodel(type_: type) -> bool:
374395
"""Returns whether or not the given type is either a `BaseModel` or a union of `BaseModel`"""
375396
if is_union(type_):
@@ -439,7 +460,7 @@ def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]
439460
type_ = type_.__value__ # type: ignore[unreachable]
440461

441462
# unwrap `Annotated[T, ...]` -> `T`
442-
if metadata is not None:
463+
if metadata is not None and len(metadata) > 0:
443464
meta: tuple[Any, ...] = tuple(metadata)
444465
elif is_annotated_type(type_):
445466
meta = get_args(type_)[1:]

src/finch/_version.py

Lines changed: 1 addition & 1 deletion
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.30.3" # x-release-please-version
4+
__version__ = "1.31.0" # x-release-please-version

src/finch/types/hris/benefit_create_params.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from typing import Iterable, Optional
6-
from typing_extensions import Literal, TypedDict
6+
from typing_extensions import Literal, Required, TypedDict
77

88
from .benefit_type import BenefitType
99
from .benefit_frequency import BenefitFrequency
@@ -30,12 +30,12 @@ class BenefitCreateParams(TypedDict, total=False):
3030

3131

3232
class CompanyContributionTier(TypedDict, total=False):
33-
match: int
33+
match: Required[int]
3434

35-
threshold: int
35+
threshold: Required[int]
3636

3737

3838
class CompanyContribution(TypedDict, total=False):
39-
tiers: Iterable[CompanyContributionTier]
39+
tiers: Required[Iterable[CompanyContributionTier]]
4040

41-
type: Literal["match"]
41+
type: Required[Literal["match"]]

src/finch/types/hris/benefit_frequency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
__all__ = ["BenefitFrequency"]
77

8-
BenefitFrequency: TypeAlias = Optional[Literal["one_time", "every_paycheck", "monthly"]]
8+
BenefitFrequency: TypeAlias = Optional[Literal["every_paycheck", "monthly", "one_time"]]

0 commit comments

Comments
 (0)