diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f3dbfd2a..b33e9fd7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.26.0" + ".": "1.26.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c389e9..3bb44d97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## 1.26.1 (2025-05-09) + +Full Changelog: [v1.26.0...v1.26.1](https://github.com/Finch-API/finch-api-python/compare/v1.26.0...v1.26.1) + +### Bug Fixes + +* **package:** support direct resource imports ([d2062bb](https://github.com/Finch-API/finch-api-python/commit/d2062bbf18bd0345c9e53019661359198f970a57)) + + +### Chores + +* fix formatting ([75885aa](https://github.com/Finch-API/finch-api-python/commit/75885aa2ab70df9b3916ceb3444b943b4df22153)) +* **internal:** avoid lint errors in pagination expressions ([5dce648](https://github.com/Finch-API/finch-api-python/commit/5dce648eafef19e583d80f71dfa95af0b7235640)) + + +### Documentation + +* remove or fix invalid readme examples ([e3d4bfd](https://github.com/Finch-API/finch-api-python/commit/e3d4bfd1ad22f6422739b7aefc3c0fc4a7d1b6e7)) + ## 1.26.0 (2025-05-08) Full Changelog: [v1.25.0...v1.26.0](https://github.com/Finch-API/finch-api-python/compare/v1.25.0...v1.26.0) diff --git a/README.md b/README.md index b1b54166..dd9945f6 100644 --- a/README.md +++ b/README.md @@ -131,19 +131,6 @@ for directory in first_page.individuals: # Remove `await` for non-async usage. ``` -## Nested params - -Nested parameters are dictionaries, typed using `TypedDict`, for example: - -```python -from finch import Finch - -client = Finch() - -page = client.hris.directory.list() -print(page.individuals) -``` - ## Webhook Verification We provide helper methods for verifying that a webhook request came from Finch, and not a malicious third party. diff --git a/pyproject.toml b/pyproject.toml index a7b77913..f9ddadbb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "finch-api" -version = "1.26.0" +version = "1.26.1" description = "The official Python library for the Finch API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/finch/__init__.py b/src/finch/__init__.py index b46d4f6e..181d238f 100644 --- a/src/finch/__init__.py +++ b/src/finch/__init__.py @@ -1,5 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +import typing as _t + from . import types from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes from ._utils import file_from_path @@ -68,6 +70,9 @@ "DefaultAsyncHttpxClient", ] +if not _t.TYPE_CHECKING: + from ._utils._resources_proxy import resources as resources + _setup_logging() # Update the __module__ attribute for exported symbols so that diff --git a/src/finch/_client.py b/src/finch/_client.py index de8bcd6d..f08e2199 100644 --- a/src/finch/_client.py +++ b/src/finch/_client.py @@ -33,7 +33,18 @@ ) if TYPE_CHECKING: - from .resources import hris, jobs, webhooks, account, connect, payroll, sandbox, providers, access_tokens, request_forwarding + from .resources import ( + hris, + jobs, + account, + connect, + payroll, + sandbox, + webhooks, + providers, + access_tokens, + request_forwarding, + ) from .resources.account import Account, AsyncAccount from .resources.hris.hris import HRIS, AsyncHRIS from .resources.jobs.jobs import Jobs, AsyncJobs diff --git a/src/finch/_utils/_resources_proxy.py b/src/finch/_utils/_resources_proxy.py new file mode 100644 index 00000000..ed527ac1 --- /dev/null +++ b/src/finch/_utils/_resources_proxy.py @@ -0,0 +1,24 @@ +from __future__ import annotations + +from typing import Any +from typing_extensions import override + +from ._proxy import LazyProxy + + +class ResourcesProxy(LazyProxy[Any]): + """A proxy for the `finch.resources` module. + + This is used so that we can lazily import `finch.resources` only when + needed *and* so that users can just import `finch` and reference `finch.resources` + """ + + @override + def __load__(self) -> Any: + import importlib + + mod = importlib.import_module("finch.resources") + return mod + + +resources = ResourcesProxy().__as_proxied__() diff --git a/src/finch/_version.py b/src/finch/_version.py index 4d845766..3b5c8103 100644 --- a/src/finch/_version.py +++ b/src/finch/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "finch" -__version__ = "1.26.0" # x-release-please-version +__version__ = "1.26.1" # x-release-please-version diff --git a/src/finch/pagination.py b/src/finch/pagination.py index 53b07949..13629525 100644 --- a/src/finch/pagination.py +++ b/src/finch/pagination.py @@ -138,6 +138,8 @@ def next_page_info(self) -> Optional[PageInfo]: if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.offset is not None: # pyright: ignore[reportUnnecessaryComparison] offset = self.paging.offset + if offset is None: + return None # type: ignore[unreachable] length = len(self._get_page_items()) current_count = offset + length @@ -173,6 +175,8 @@ def next_page_info(self) -> Optional[PageInfo]: if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.offset is not None: # pyright: ignore[reportUnnecessaryComparison] offset = self.paging.offset + if offset is None: + return None # type: ignore[unreachable] length = len(self._get_page_items()) current_count = offset + length @@ -207,6 +211,8 @@ def next_page_info(self) -> Optional[PageInfo]: if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.offset is not None: # pyright: ignore[reportUnnecessaryComparison] offset = self.paging.offset + if offset is None: + return None # type: ignore[unreachable] length = len(self._get_page_items()) current_count = offset + length @@ -241,6 +247,8 @@ def next_page_info(self) -> Optional[PageInfo]: if self.paging is not None: # pyright: ignore[reportUnnecessaryComparison] if self.paging.offset is not None: # pyright: ignore[reportUnnecessaryComparison] offset = self.paging.offset + if offset is None: + return None # type: ignore[unreachable] length = len(self._get_page_items()) current_count = offset + length diff --git a/tests/api_resources/test_access_tokens.py b/tests/api_resources/test_access_tokens.py index ad26c0d4..1a4cd3fe 100644 --- a/tests/api_resources/test_access_tokens.py +++ b/tests/api_resources/test_access_tokens.py @@ -12,7 +12,6 @@ from tests.utils import assert_matches_type if TYPE_CHECKING: - from _pytest.fixtures import FixtureRequest # pyright: ignore[reportPrivateImportUsage] base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")