From a0ee12f2c148dc3f411eb374cbca767cb8c5a8a9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 22:26:59 +0000 Subject: [PATCH] feat(api): api update (#513) --- pyproject.toml | 8 ++----- requirements-dev.lock | 2 +- src/finch/_base_client.py | 2 +- src/finch/_client.py | 4 ++-- .../types/connect/session_new_response.py | 1 - .../session_reauthenticate_response.py | 1 - src/finch/types/disconnect_response.py | 1 - src/finch/types/hris/benfit_contribution.py | 1 - .../hris/create_company_benefits_response.py | 1 - .../hris/update_company_benefit_response.py | 1 - .../types/jobs/automated_create_response.py | 1 - .../types/sandbox/job_create_response.py | 1 - .../types/sandbox/payment_create_response.py | 1 - tests/test_client.py | 21 +++++++++++++++++-- tests/test_models.py | 2 +- 15 files changed, 26 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e8d61188..2967dbf6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,11 +63,11 @@ format = { chain = [ "format:ruff", "format:docs", "fix:ruff", + # run formatting again to fix any inconsistencies when imports are stripped + "format:ruff", ]} -"format:black" = "black ." "format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md" "format:ruff" = "ruff format" -"format:isort" = "isort ." "lint" = { chain = [ "check:ruff", @@ -125,10 +125,6 @@ path = "README.md" pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)' replacement = '[\1](https://github.com/Finch-API/finch-api-python/tree/main/\g<2>)' -[tool.black] -line-length = 120 -target-version = ["py37"] - [tool.pytest.ini_options] testpaths = ["tests"] addopts = "--tb=short" diff --git a/requirements-dev.lock b/requirements-dev.lock index 53209e90..213a0e0e 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -80,7 +80,7 @@ pytz==2023.3.post1 # via dirty-equals respx==0.20.2 rich==13.7.1 -ruff==0.6.5 +ruff==0.6.9 setuptools==68.2.2 # via nodeenv six==1.16.0 diff --git a/src/finch/_base_client.py b/src/finch/_base_client.py index 739b07cb..9f0e0efc 100644 --- a/src/finch/_base_client.py +++ b/src/finch/_base_client.py @@ -1590,7 +1590,7 @@ async def _request( except Exception as err: log.debug("Encountered Exception", exc_info=True) - if retries_taken > 0: + if remaining_retries > 0: return await self._retry_request( input_options, cast_to, diff --git a/src/finch/_client.py b/src/finch/_client.py index 38117c5d..457b2d33 100644 --- a/src/finch/_client.py +++ b/src/finch/_client.py @@ -159,7 +159,7 @@ def __init__( @property @override def qs(self) -> Querystring: - return Querystring(array_format="comma") + return Querystring(array_format="brackets") @property @override @@ -495,7 +495,7 @@ def __init__( @property @override def qs(self) -> Querystring: - return Querystring(array_format="comma") + return Querystring(array_format="brackets") @property @override diff --git a/src/finch/types/connect/session_new_response.py b/src/finch/types/connect/session_new_response.py index 2faa96c3..cf343973 100644 --- a/src/finch/types/connect/session_new_response.py +++ b/src/finch/types/connect/session_new_response.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - from ..._models import BaseModel __all__ = ["SessionNewResponse"] diff --git a/src/finch/types/connect/session_reauthenticate_response.py b/src/finch/types/connect/session_reauthenticate_response.py index 1f28765a..323ebf71 100644 --- a/src/finch/types/connect/session_reauthenticate_response.py +++ b/src/finch/types/connect/session_reauthenticate_response.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - from ..._models import BaseModel __all__ = ["SessionReauthenticateResponse"] diff --git a/src/finch/types/disconnect_response.py b/src/finch/types/disconnect_response.py index d30ec36c..ae2efc6d 100644 --- a/src/finch/types/disconnect_response.py +++ b/src/finch/types/disconnect_response.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - from .._models import BaseModel __all__ = ["DisconnectResponse"] diff --git a/src/finch/types/hris/benfit_contribution.py b/src/finch/types/hris/benfit_contribution.py index ca806127..9a07b032 100644 --- a/src/finch/types/hris/benfit_contribution.py +++ b/src/finch/types/hris/benfit_contribution.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - from .benefit_contribution import BenefitContribution __all__ = ["BenfitContribution"] diff --git a/src/finch/types/hris/create_company_benefits_response.py b/src/finch/types/hris/create_company_benefits_response.py index 105cec00..176c024d 100644 --- a/src/finch/types/hris/create_company_benefits_response.py +++ b/src/finch/types/hris/create_company_benefits_response.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - from ..._models import BaseModel __all__ = ["CreateCompanyBenefitsResponse"] diff --git a/src/finch/types/hris/update_company_benefit_response.py b/src/finch/types/hris/update_company_benefit_response.py index 9cc7e992..de9f25b0 100644 --- a/src/finch/types/hris/update_company_benefit_response.py +++ b/src/finch/types/hris/update_company_benefit_response.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - from ..._models import BaseModel __all__ = ["UpdateCompanyBenefitResponse"] diff --git a/src/finch/types/jobs/automated_create_response.py b/src/finch/types/jobs/automated_create_response.py index cb3159b9..8ff5d991 100644 --- a/src/finch/types/jobs/automated_create_response.py +++ b/src/finch/types/jobs/automated_create_response.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - from ..._models import BaseModel __all__ = ["AutomatedCreateResponse"] diff --git a/src/finch/types/sandbox/job_create_response.py b/src/finch/types/sandbox/job_create_response.py index 80bc795d..f8e39f16 100644 --- a/src/finch/types/sandbox/job_create_response.py +++ b/src/finch/types/sandbox/job_create_response.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - from ..._models import BaseModel __all__ = ["JobCreateResponse"] diff --git a/src/finch/types/sandbox/payment_create_response.py b/src/finch/types/sandbox/payment_create_response.py index 6b31d415..028bbde5 100644 --- a/src/finch/types/sandbox/payment_create_response.py +++ b/src/finch/types/sandbox/payment_create_response.py @@ -1,7 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - from ..._models import BaseModel __all__ = ["PaymentCreateResponse"] diff --git a/tests/test_client.py b/tests/test_client.py index 4641bf7d..4ee66df5 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -10,6 +10,7 @@ import tracemalloc from typing import Any, Union, cast from unittest import mock +from typing_extensions import Literal import httpx import pytest @@ -824,7 +825,14 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) @mock.patch("finch._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) - def test_retries_taken(self, client: Finch, failures_before_success: int, respx_mock: MockRouter) -> None: + @pytest.mark.parametrize("failure_mode", ["status", "exception"]) + def test_retries_taken( + self, + client: Finch, + failures_before_success: int, + failure_mode: Literal["status", "exception"], + respx_mock: MockRouter, + ) -> None: client = client.with_options(max_retries=4) nb_retries = 0 @@ -833,6 +841,8 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: nonlocal nb_retries if nb_retries < failures_before_success: nb_retries += 1 + if failure_mode == "exception": + raise RuntimeError("oops") return httpx.Response(500) return httpx.Response(200) @@ -1704,8 +1714,13 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte @mock.patch("finch._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) @pytest.mark.asyncio + @pytest.mark.parametrize("failure_mode", ["status", "exception"]) async def test_retries_taken( - self, async_client: AsyncFinch, failures_before_success: int, respx_mock: MockRouter + self, + async_client: AsyncFinch, + failures_before_success: int, + failure_mode: Literal["status", "exception"], + respx_mock: MockRouter, ) -> None: client = async_client.with_options(max_retries=4) @@ -1715,6 +1730,8 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: nonlocal nb_retries if nb_retries < failures_before_success: nb_retries += 1 + if failure_mode == "exception": + raise RuntimeError("oops") return httpx.Response(500) return httpx.Response(200) diff --git a/tests/test_models.py b/tests/test_models.py index 786b717d..1fbb88d9 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -245,7 +245,7 @@ class Model(BaseModel): assert m.foo is True m = Model.construct(foo="CARD_HOLDER") - assert m.foo is "CARD_HOLDER" + assert m.foo == "CARD_HOLDER" m = Model.construct(foo={"bar": False}) assert isinstance(m.foo, Submodel1)