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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ jobs:
run: ./scripts/lint

build:
if: github.repository == 'stainless-sdks/finch-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
timeout-minutes: 10
name: build
permissions:
contents: read
id-token: write
runs-on: depot-ubuntu-24.04
runs-on: ${{ github.repository == 'stainless-sdks/finch-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

Expand All @@ -61,12 +61,14 @@ jobs:
run: rye build

- name: Get GitHub OIDC Token
if: github.repository == 'stainless-sdks/finch-python'
id: github-oidc
uses: actions/github-script@v6
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
if: github.repository == 'stainless-sdks/finch-python'
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
Expand Down
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.34.0"
".": "1.35.0"
}
4 changes: 2 additions & 2 deletions .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-6d0c6a1feba5ccb895a6779cd98c2a0ae87d6394f5e98a9da51f17258c4eb297.yml
openapi_spec_hash: ac3be0c8a992103e5f467fe1bcb20a81
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bf86910e96e83e583689cf5d1a5c583268754026ec68288994fa6a969dc248f2.yml
openapi_spec_hash: 195038e056891afec204c49dadce3b95
config_hash: 5146b12344dae76238940989dac1e8a0
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 1.35.0 (2025-09-02)

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

### Features

* **api:** api update ([7f1f3fc](https://github.com/Finch-API/finch-api-python/commit/7f1f3fcb12b896ae43df668d6825e6de895a0843))
* **types:** replace List[str] with SequenceNotStr in params ([7d41d8f](https://github.com/Finch-API/finch-api-python/commit/7d41d8fe116a14351d2f6aa569733c039f9a071f))


### Bug Fixes

* avoid newer type syntax ([c180618](https://github.com/Finch-API/finch-api-python/commit/c18061816f2c5d81d958cbf0fd7fd16b95fa7371))


### Chores

* **internal:** add Sequence related utils ([1c99d3a](https://github.com/Finch-API/finch-api-python/commit/1c99d3a79c85da901f81bfc94daa64317aedef19))
* **internal:** change ci workflow machines ([825d163](https://github.com/Finch-API/finch-api-python/commit/825d1637f7058c3d80092b6b07146653cc76432f))
* **internal:** minor formatting change ([7f1c96d](https://github.com/Finch-API/finch-api-python/commit/7f1c96d1ef47db7be85a93e602bfa612e50f04c1))
* **internal:** update pyright exclude list ([7b620cc](https://github.com/Finch-API/finch-api-python/commit/7b620cc5f0a89e2d1aab02065ff0af4e87b022ff))
* update github action ([5067831](https://github.com/Finch-API/finch-api-python/commit/50678319366698ef0d8ea19b6ae6d383e8b3725c))

## 1.34.0 (2025-08-20)

Full Changelog: [v1.33.0...v1.34.0](https://github.com/Finch-API/finch-api-python/compare/v1.33.0...v1.34.0)
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "finch-api"
version = "1.34.0"
version = "1.35.0"
description = "The official Python library for the Finch API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -148,6 +148,7 @@ exclude = [
"_dev",
".venv",
".nox",
".git",
]

reportImplicitOverride = true
Expand Down
2 changes: 1 addition & 1 deletion src/finch/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def model_dump(
exclude_none=exclude_none,
)

return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
return cast("dict[str, Any]", json_safe(dumped)) if mode == "json" else dumped

@override
def model_dump_json(
Expand Down
36 changes: 35 additions & 1 deletion src/finch/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@
Mapping,
TypeVar,
Callable,
Iterator,
Optional,
Sequence,
)
from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
from typing_extensions import (
Set,
Literal,
Protocol,
TypeAlias,
TypedDict,
SupportsIndex,
overload,
override,
runtime_checkable,
)

import httpx
import pydantic
Expand Down Expand Up @@ -219,3 +230,26 @@ class _GenericAlias(Protocol):
class HttpxSendArgs(TypedDict, total=False):
auth: httpx.Auth
follow_redirects: bool


_T_co = TypeVar("_T_co", covariant=True)


if TYPE_CHECKING:
# This works because str.__contains__ does not accept object (either in typeshed or at runtime)
# https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285
class SequenceNotStr(Protocol[_T_co]):
@overload
def __getitem__(self, index: SupportsIndex, /) -> _T_co: ...
@overload
def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ...
def __contains__(self, value: object, /) -> bool: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_T_co]: ...
def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ...
def count(self, value: Any, /) -> int: ...
def __reversed__(self) -> Iterator[_T_co]: ...
else:
# just point this to a normal `Sequence` at runtime to avoid having to special case
# deserializing our custom sequence type
SequenceNotStr = Sequence
1 change: 1 addition & 0 deletions src/finch/_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
extract_type_arg as extract_type_arg,
is_iterable_type as is_iterable_type,
is_required_type as is_required_type,
is_sequence_type as is_sequence_type,
is_annotated_type as is_annotated_type,
is_type_alias_type as is_type_alias_type,
strip_annotated_type as strip_annotated_type,
Expand Down
6 changes: 6 additions & 0 deletions src/finch/_utils/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
lru_cache,
is_mapping,
is_iterable,
is_sequence,
)
from .._files import is_base64_file_input
from ._typing import (
Expand All @@ -24,6 +25,7 @@
extract_type_arg,
is_iterable_type,
is_required_type,
is_sequence_type,
is_annotated_type,
strip_annotated_type,
)
Expand Down Expand Up @@ -184,6 +186,8 @@ def _transform_recursive(
(is_list_type(stripped_type) and is_list(data))
# Iterable[T]
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
# Sequence[T]
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
):
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
# intended as an iterable, so we don't transform it.
Expand Down Expand Up @@ -346,6 +350,8 @@ async def _async_transform_recursive(
(is_list_type(stripped_type) and is_list(data))
# Iterable[T]
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
# Sequence[T]
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
):
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
# intended as an iterable, so we don't transform it.
Expand Down
5 changes: 5 additions & 0 deletions src/finch/_utils/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def is_list_type(typ: type) -> bool:
return (get_origin(typ) or typ) == list


def is_sequence_type(typ: type) -> bool:
origin = get_origin(typ) or typ
return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence


def is_iterable_type(typ: type) -> bool:
"""If the given type is `typing.Iterable[T]`"""
origin = get_origin(typ) or typ
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.34.0" # x-release-please-version
__version__ = "1.35.0" # x-release-please-version
8 changes: 4 additions & 4 deletions src/finch/resources/hris/benefits/individuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from __future__ import annotations

from typing import List, Iterable
from typing import Iterable

import httpx

from .... import _legacy_response
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
from ...._utils import maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -170,7 +170,7 @@ def unenroll_many(
self,
benefit_id: str,
*,
individual_ids: List[str] | NotGiven = NOT_GIVEN,
individual_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -349,7 +349,7 @@ async def unenroll_many(
self,
benefit_id: str,
*,
individual_ids: List[str] | NotGiven = NOT_GIVEN,
individual_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
8 changes: 4 additions & 4 deletions src/finch/resources/hris/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def __init__(self, directory: Directory) -> None:
)
self.list_individuals = ( # pyright: ignore[reportDeprecated]
_legacy_response.to_raw_response_wrapper(
directory.list_individuals # pyright: ignore[reportDeprecated],
directory.list_individuals, # pyright: ignore[reportDeprecated],
)
)

Expand All @@ -255,7 +255,7 @@ def __init__(self, directory: AsyncDirectory) -> None:
)
self.list_individuals = ( # pyright: ignore[reportDeprecated]
_legacy_response.async_to_raw_response_wrapper(
directory.list_individuals # pyright: ignore[reportDeprecated],
directory.list_individuals, # pyright: ignore[reportDeprecated],
)
)

Expand All @@ -269,7 +269,7 @@ def __init__(self, directory: Directory) -> None:
)
self.list_individuals = ( # pyright: ignore[reportDeprecated]
to_streamed_response_wrapper(
directory.list_individuals # pyright: ignore[reportDeprecated],
directory.list_individuals, # pyright: ignore[reportDeprecated],
)
)

Expand All @@ -283,6 +283,6 @@ def __init__(self, directory: AsyncDirectory) -> None:
)
self.list_individuals = ( # pyright: ignore[reportDeprecated]
async_to_streamed_response_wrapper(
directory.list_individuals # pyright: ignore[reportDeprecated],
directory.list_individuals, # pyright: ignore[reportDeprecated],
)
)
6 changes: 3 additions & 3 deletions src/finch/resources/hris/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import httpx

from ... import _legacy_response
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
from ..._utils import maybe_transform, async_maybe_transform
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -44,7 +44,7 @@ def with_streaming_response(self) -> DocumentsWithStreamingResponse:
def list(
self,
*,
individual_ids: List[str] | NotGiven = NOT_GIVEN,
individual_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
offset: int | NotGiven = NOT_GIVEN,
types: List[Literal["w4_2020", "w4_2005"]] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -163,7 +163,7 @@ def with_streaming_response(self) -> AsyncDocumentsWithStreamingResponse:
async def list(
self,
*,
individual_ids: List[str] | NotGiven = NOT_GIVEN,
individual_ids: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
offset: int | NotGiven = NOT_GIVEN,
types: List[Literal["w4_2020", "w4_2005"]] | NotGiven = NOT_GIVEN,
Expand Down
8 changes: 3 additions & 5 deletions src/finch/resources/payroll/pay_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

from __future__ import annotations

from typing import List

import httpx

from ... import _legacy_response
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
from ..._utils import maybe_transform
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -78,7 +76,7 @@ def list(
self,
*,
individual_id: str | NotGiven = NOT_GIVEN,
pay_frequencies: List[str] | NotGiven = NOT_GIVEN,
pay_frequencies: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -175,7 +173,7 @@ def list(
self,
*,
individual_id: str | NotGiven = NOT_GIVEN,
pay_frequencies: List[str] | NotGiven = NOT_GIVEN,
pay_frequencies: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
7 changes: 3 additions & 4 deletions src/finch/resources/sandbox/connections/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

from __future__ import annotations

from typing import List
from typing_extensions import Literal

import httpx

from .... import _legacy_response
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, SequenceNotStr
from ...._utils import maybe_transform, async_maybe_transform
from ...._compat import cached_property
from ...._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -48,7 +47,7 @@ def create(
company_id: str,
provider_id: str,
authentication_type: Literal["credential", "api_token", "oauth", "assisted"] | NotGiven = NOT_GIVEN,
products: List[str] | NotGiven = NOT_GIVEN,
products: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -151,7 +150,7 @@ async def create(
company_id: str,
provider_id: str,
authentication_type: Literal["credential", "api_token", "oauth", "assisted"] | NotGiven = NOT_GIVEN,
products: List[str] | NotGiven = NOT_GIVEN,
products: SequenceNotStr[str] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
Loading