Skip to content

release: 1.14.0 #581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 8, 2025
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
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
lint:
name: lint
runs-on: ubuntu-latest


steps:
- uses: actions/checkout@v4
Expand All @@ -30,6 +29,7 @@ jobs:

- name: Run lints
run: ./scripts/lint

test:
name: test
runs-on: ubuntu-latest
Expand All @@ -50,4 +50,3 @@ jobs:

- name: Run tests
run: ./scripts/test

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.13.3"
".": "1.14.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 41
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-77520f5037161db86208e3a9d3f36f39e971a8ee10b1d9972a22c084fcf21845.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-97bf4795deec23d1bfd3b0b5fd77c2a93c87f10e5fa3375ab30f4a877be97f53.yml
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## 1.14.0 (2025-02-06)

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

### Features

* **api:** api update ([#582](https://github.com/Finch-API/finch-api-python/issues/582)) ([1568147](https://github.com/Finch-API/finch-api-python/commit/1568147b9ba15f131b87d34fbb4b66f0049b160e))
* **api:** api update ([#584](https://github.com/Finch-API/finch-api-python/issues/584)) ([79bb13f](https://github.com/Finch-API/finch-api-python/commit/79bb13f68f07f41ef9342110bf481f3d134644a4))
* **api:** api update ([#585](https://github.com/Finch-API/finch-api-python/issues/585)) ([fe082cb](https://github.com/Finch-API/finch-api-python/commit/fe082cb9386df1bf4cd0e897505b8e7d750bd53b))
* **client:** send `X-Stainless-Read-Timeout` header ([#588](https://github.com/Finch-API/finch-api-python/issues/588)) ([70ca350](https://github.com/Finch-API/finch-api-python/commit/70ca350878ae0e7b9f5c7ef4bbcd8f086cf91dd8))


### Chores

* **internal:** bummp ruff dependency ([#587](https://github.com/Finch-API/finch-api-python/issues/587)) ([592b7cc](https://github.com/Finch-API/finch-api-python/commit/592b7ccde3e2d8071aa030bde5cf24264b0d865b))
* **internal:** change default timeout to an int ([#586](https://github.com/Finch-API/finch-api-python/issues/586)) ([4835451](https://github.com/Finch-API/finch-api-python/commit/4835451ae07ada92da7b531088d6a950f0009f63))
* **internal:** codegen related update ([#583](https://github.com/Finch-API/finch-api-python/issues/583)) ([a26a626](https://github.com/Finch-API/finch-api-python/commit/a26a626a063c71cd055068a288ae53f543d73144))
* **internal:** fix type traversing dictionary params ([#589](https://github.com/Finch-API/finch-api-python/issues/589)) ([b3157d7](https://github.com/Finch-API/finch-api-python/commit/b3157d73258d1a1976e6d9155f8b210e175de57c))
* **internal:** minor formatting changes ([#580](https://github.com/Finch-API/finch-api-python/issues/580)) ([63a905c](https://github.com/Finch-API/finch-api-python/commit/63a905c643203ca1e525f02f66b73800ecd83416))
* **internal:** minor type handling changes ([#590](https://github.com/Finch-API/finch-api-python/issues/590)) ([f37f226](https://github.com/Finch-API/finch-api-python/commit/f37f226ff334f387a6c1a5fe1f1fa18c31533a47))

## 1.13.3 (2025-01-21)

Full Changelog: [v1.13.2...v1.13.3](https://github.com/Finch-API/finch-api-python/compare/v1.13.2...v1.13.3)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "finch-api"
version = "1.13.3"
version = "1.14.0"
description = "The official Python library for the Finch API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -177,7 +177,7 @@ select = [
"T201",
"T203",
# misuse of typing.TYPE_CHECKING
"TCH004",
"TC004",
# import rules
"TID251",
]
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pytz==2023.3.post1
# via dirty-equals
respx==0.22.0
rich==13.7.1
ruff==0.6.9
ruff==0.9.4
setuptools==68.2.2
# via nodeenv
six==1.16.0
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
if ! command -v rye >/dev/null 2>&1 && [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
Expand Down
1 change: 0 additions & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ rye run lint

echo "==> Making sure it imports"
rye run python -c 'import finch'

4 changes: 2 additions & 2 deletions scripts/utils/ruffen-docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _md_match(match: Match[str]) -> str:
with _collect_error(match):
code = format_code_block(code)
code = textwrap.indent(code, match["indent"])
return f'{match["before"]}{code}{match["after"]}'
return f"{match['before']}{code}{match['after']}"

def _pycon_match(match: Match[str]) -> str:
code = ""
Expand Down Expand Up @@ -97,7 +97,7 @@ def finish_fragment() -> None:
def _md_pycon_match(match: Match[str]) -> str:
code = _pycon_match(match)
code = textwrap.indent(code, match["indent"])
return f'{match["before"]}{code}{match["after"]}'
return f"{match['before']}{code}{match['after']}"

src = MD_RE.sub(_md_match, src)
src = MD_PYCON_RE.sub(_md_pycon_match, src)
Expand Down
11 changes: 9 additions & 2 deletions src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,17 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0
if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers:
headers[idempotency_header] = options.idempotency_key or self._idempotency_key()

# Don't set the retry count header if it was already set or removed by the caller. We check
# Don't set these headers if they were already set or removed by the caller. We check
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
if "x-stainless-retry-count" not in (header.lower() for header in custom_headers):
lower_custom_headers = [header.lower() for header in custom_headers]
if "x-stainless-retry-count" not in lower_custom_headers:
headers["x-stainless-retry-count"] = str(retries_taken)
if "x-stainless-read-timeout" not in lower_custom_headers:
timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout
if isinstance(timeout, Timeout):
timeout = timeout.read
if timeout is not None:
headers["x-stainless-read-timeout"] = str(timeout)

return headers

Expand Down
2 changes: 1 addition & 1 deletion src/finch/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OVERRIDE_CAST_TO_HEADER = "____stainless_override_cast_to"

# default timeout is 1 minute
DEFAULT_TIMEOUT = httpx.Timeout(timeout=60.0, connect=5.0)
DEFAULT_TIMEOUT = httpx.Timeout(timeout=60, connect=5.0)
DEFAULT_MAX_RETRIES = 2
DEFAULT_CONNECTION_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20)

Expand Down
10 changes: 8 additions & 2 deletions src/finch/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def to_json(
@override
def __str__(self) -> str:
# mypy complains about an invalid self arg
return f'{self.__repr_name__()}({self.__repr_str__(", ")})' # type: ignore[misc]
return f"{self.__repr_name__()}({self.__repr_str__(', ')})" # type: ignore[misc]

# Override the 'construct' method in a way that supports recursive parsing without validation.
# Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
Expand Down Expand Up @@ -426,10 +426,16 @@ def construct_type(*, value: object, type_: object) -> object:

If the given value does not match the expected type then it is returned as-is.
"""

# store a reference to the original type we were given before we extract any inner
# types so that we can properly resolve forward references in `TypeAliasType` annotations
original_type = None

# we allow `object` as the input type because otherwise, passing things like
# `Literal['value']` will be reported as a type error by type checkers
type_ = cast("type[object]", type_)
if is_type_alias_type(type_):
original_type = type_ # type: ignore[unreachable]
type_ = type_.__value__ # type: ignore[unreachable]

# unwrap `Annotated[T, ...]` -> `T`
Expand All @@ -446,7 +452,7 @@ def construct_type(*, value: object, type_: object) -> object:

if is_union(origin):
try:
return validate_type(type_=cast("type[object]", type_), value=value)
return validate_type(type_=cast("type[object]", original_type or type_), value=value)
except Exception:
pass

Expand Down
12 changes: 11 additions & 1 deletion src/finch/_utils/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
is_annotated_type,
strip_annotated_type,
)
from .._compat import model_dump, is_typeddict
from .._compat import get_origin, model_dump, is_typeddict

_T = TypeVar("_T")

Expand Down Expand Up @@ -164,9 +164,14 @@ def _transform_recursive(
inner_type = annotation

stripped_type = strip_annotated_type(inner_type)
origin = get_origin(stripped_type) or stripped_type
if is_typeddict(stripped_type) and is_mapping(data):
return _transform_typeddict(data, stripped_type)

if origin == dict and is_mapping(data):
items_type = get_args(stripped_type)[1]
return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()}

if (
# List[T]
(is_list_type(stripped_type) and is_list(data))
Expand Down Expand Up @@ -307,9 +312,14 @@ async def _async_transform_recursive(
inner_type = annotation

stripped_type = strip_annotated_type(inner_type)
origin = get_origin(stripped_type) or stripped_type
if is_typeddict(stripped_type) and is_mapping(data):
return await _async_transform_typeddict(data, stripped_type)

if origin == dict and is_mapping(data):
items_type = get_args(stripped_type)[1]
return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()}

if (
# List[T]
(is_list_type(stripped_type) and is_list(data))
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.13.3" # x-release-please-version
__version__ = "1.14.0" # x-release-please-version
48 changes: 44 additions & 4 deletions src/finch/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,17 @@ def next_page_info(self) -> Optional[PageInfo]:
length = len(self._get_page_items())
current_count = offset + length

return PageInfo(params={"offset": current_count})
count = 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:
return None

if current_count < count:
return PageInfo(params={"offset": current_count})

return None


class AsyncIndividualsPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
Expand All @@ -171,7 +181,17 @@ def next_page_info(self) -> Optional[PageInfo]:
length = len(self._get_page_items())
current_count = offset + length

return PageInfo(params={"offset": current_count})
count = 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:
return None

if current_count < count:
return PageInfo(params={"offset": current_count})

return None


class SyncPage(BaseSyncPage[_T], BasePage[_T], Generic[_T]):
Expand All @@ -197,7 +217,17 @@ def next_page_info(self) -> Optional[PageInfo]:
length = len(self._get_page_items())
current_count = offset + length

return PageInfo(params={"offset": current_count})
count = 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:
return None

if current_count < count:
return PageInfo(params={"offset": current_count})

return None


class AsyncPage(BaseAsyncPage[_T], BasePage[_T], Generic[_T]):
Expand All @@ -223,4 +253,14 @@ def next_page_info(self) -> Optional[PageInfo]:
length = len(self._get_page_items())
current_count = offset + length

return PageInfo(params={"offset": current_count})
count = 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:
return None

if current_count < count:
return PageInfo(params={"offset": current_count})

return None
8 changes: 4 additions & 4 deletions src/finch/resources/connect/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def new(
Create a new connect session for an employer

Args:
minutes_to_expire: The number of minutes until the session expires (defaults to 20,160, which is 14
minutes_to_expire: The number of minutes until the session expires (defaults to 43,200, which is 30
days)

extra_headers: Send extra headers
Expand Down Expand Up @@ -129,7 +129,7 @@ def reauthenticate(
Args:
connection_id: The ID of the existing connection to reauthenticate

minutes_to_expire: The number of minutes until the session expires (defaults to 20,160, which is 14
minutes_to_expire: The number of minutes until the session expires (defaults to 43,200, which is 30
days)

products: The products to request access to (optional for reauthentication)
Expand Down Expand Up @@ -207,7 +207,7 @@ async def new(
Create a new connect session for an employer

Args:
minutes_to_expire: The number of minutes until the session expires (defaults to 20,160, which is 14
minutes_to_expire: The number of minutes until the session expires (defaults to 43,200, which is 30
days)

extra_headers: Send extra headers
Expand Down Expand Up @@ -267,7 +267,7 @@ async def reauthenticate(
Args:
connection_id: The ID of the existing connection to reauthenticate

minutes_to_expire: The number of minutes until the session expires (defaults to 20,160, which is 14
minutes_to_expire: The number of minutes until the session expires (defaults to 43,200, which is 30
days)

products: The products to request access to (optional for reauthentication)
Expand Down
Loading