Skip to content

Commit

Permalink
feat(api): api update (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Oct 23, 2024
1 parent fab3cd1 commit 32e705f
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 22 deletions.
8 changes: 2 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/finch/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __init__(
@property
@override
def qs(self) -> Querystring:
return Querystring(array_format="comma")
return Querystring(array_format="brackets")

@property
@override
Expand Down Expand Up @@ -495,7 +495,7 @@ def __init__(
@property
@override
def qs(self) -> Querystring:
return Querystring(array_format="comma")
return Querystring(array_format="brackets")

@property
@override
Expand Down
1 change: 0 additions & 1 deletion src/finch/types/connect/session_new_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.



from ..._models import BaseModel

__all__ = ["SessionNewResponse"]
Expand Down
1 change: 0 additions & 1 deletion src/finch/types/connect/session_reauthenticate_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.



from ..._models import BaseModel

__all__ = ["SessionReauthenticateResponse"]
Expand Down
1 change: 0 additions & 1 deletion src/finch/types/disconnect_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.



from .._models import BaseModel

__all__ = ["DisconnectResponse"]
Expand Down
1 change: 0 additions & 1 deletion src/finch/types/hris/benfit_contribution.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.



from .benefit_contribution import BenefitContribution

__all__ = ["BenfitContribution"]
Expand Down
1 change: 0 additions & 1 deletion src/finch/types/hris/create_company_benefits_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.



from ..._models import BaseModel

__all__ = ["CreateCompanyBenefitsResponse"]
Expand Down
1 change: 0 additions & 1 deletion src/finch/types/hris/update_company_benefit_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.



from ..._models import BaseModel

__all__ = ["UpdateCompanyBenefitResponse"]
Expand Down
1 change: 0 additions & 1 deletion src/finch/types/jobs/automated_create_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.



from ..._models import BaseModel

__all__ = ["AutomatedCreateResponse"]
Expand Down
1 change: 0 additions & 1 deletion src/finch/types/sandbox/job_create_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.



from ..._models import BaseModel

__all__ = ["JobCreateResponse"]
Expand Down
1 change: 0 additions & 1 deletion src/finch/types/sandbox/payment_create_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.



from ..._models import BaseModel

__all__ = ["PaymentCreateResponse"]
Expand Down
21 changes: 19 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 32e705f

Please sign in to comment.