From c240699bdac07e0059c1f81f8af305b7bcfaa4ca Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 19:34:37 +0000 Subject: [PATCH] feat(api): api update (#515) --- .stats.yml | 2 +- requirements-dev.lock | 23 ++++++++++------------- requirements.lock | 8 ++++---- src/finch/_compat.py | 2 +- src/finch/_models.py | 10 +++++----- src/finch/_types.py | 6 ++++-- src/finch/types/account_update_event.py | 13 +++++++++++++ src/finch/types/provider.py | 13 +++++++++++++ tests/conftest.py | 14 ++++++++------ 9 files changed, 59 insertions(+), 32 deletions(-) diff --git a/.stats.yml b/.stats.yml index 63c6ed1e..35c62c13 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 39 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-612b573cabcee39c562dc91f5b185e2a0bfdce3a262618f0098602af2199af67.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-b67c6cc5bff73851c98deeabb3ef7548eb89abfa88aca36886084416fdc347f4.yml diff --git a/requirements-dev.lock b/requirements-dev.lock index 213a0e0e..d7ca9688 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -16,8 +16,6 @@ anyio==4.4.0 # via httpx argcomplete==3.1.2 # via nox -attrs==23.1.0 - # via pytest certifi==2023.7.22 # via httpcore # via httpx @@ -28,8 +26,9 @@ distlib==0.3.7 # via virtualenv distro==1.8.0 # via finch-api -exceptiongroup==1.1.3 +exceptiongroup==1.2.2 # via anyio + # via pytest filelock==3.12.4 # via virtualenv h11==0.14.0 @@ -49,7 +48,7 @@ markdown-it-py==3.0.0 # via rich mdurl==0.1.2 # via markdown-it-py -mypy==1.11.2 +mypy==1.13.0 mypy-extensions==1.0.0 # via mypy nodeenv==1.8.0 @@ -60,20 +59,18 @@ packaging==23.2 # via pytest platformdirs==3.11.0 # via virtualenv -pluggy==1.3.0 - # via pytest -py==1.11.0 +pluggy==1.5.0 # via pytest -pydantic==2.7.1 +pydantic==2.9.2 # via finch-api -pydantic-core==2.18.2 +pydantic-core==2.23.4 # via pydantic pygments==2.18.0 # via rich pyright==1.1.380 -pytest==7.1.1 +pytest==8.3.3 # via pytest-asyncio -pytest-asyncio==0.21.1 +pytest-asyncio==0.24.0 python-dateutil==2.8.2 # via time-machine pytz==2023.3.post1 @@ -90,10 +87,10 @@ sniffio==1.3.0 # via finch-api # via httpx time-machine==2.9.0 -tomli==2.0.1 +tomli==2.0.2 # via mypy # via pytest -typing-extensions==4.8.0 +typing-extensions==4.12.2 # via anyio # via finch-api # via mypy diff --git a/requirements.lock b/requirements.lock index 21d017d0..205e3487 100644 --- a/requirements.lock +++ b/requirements.lock @@ -19,7 +19,7 @@ certifi==2023.7.22 # via httpx distro==1.8.0 # via finch-api -exceptiongroup==1.1.3 +exceptiongroup==1.2.2 # via anyio h11==0.14.0 # via httpcore @@ -30,15 +30,15 @@ httpx==0.25.2 idna==3.4 # via anyio # via httpx -pydantic==2.7.1 +pydantic==2.9.2 # via finch-api -pydantic-core==2.18.2 +pydantic-core==2.23.4 # via pydantic sniffio==1.3.0 # via anyio # via finch-api # via httpx -typing-extensions==4.8.0 +typing-extensions==4.12.2 # via anyio # via finch-api # via pydantic diff --git a/src/finch/_compat.py b/src/finch/_compat.py index 162a6fbe..d89920d9 100644 --- a/src/finch/_compat.py +++ b/src/finch/_compat.py @@ -133,7 +133,7 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str: def model_dump( model: pydantic.BaseModel, *, - exclude: IncEx = None, + exclude: IncEx | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, warnings: bool = True, diff --git a/src/finch/_models.py b/src/finch/_models.py index d386eaa3..42551b76 100644 --- a/src/finch/_models.py +++ b/src/finch/_models.py @@ -176,7 +176,7 @@ def __str__(self) -> str: # Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836. @classmethod @override - def construct( + def construct( # pyright: ignore[reportIncompatibleMethodOverride] cls: Type[ModelT], _fields_set: set[str] | None = None, **values: object, @@ -248,8 +248,8 @@ def model_dump( self, *, mode: Literal["json", "python"] | str = "python", - include: IncEx = None, - exclude: IncEx = None, + include: IncEx | None = None, + exclude: IncEx | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, @@ -303,8 +303,8 @@ def model_dump_json( self, *, indent: int | None = None, - include: IncEx = None, - exclude: IncEx = None, + include: IncEx | None = None, + exclude: IncEx | None = None, by_alias: bool = False, exclude_unset: bool = False, exclude_defaults: bool = False, diff --git a/src/finch/_types.py b/src/finch/_types.py index b1233fc5..06f00715 100644 --- a/src/finch/_types.py +++ b/src/finch/_types.py @@ -16,7 +16,7 @@ Optional, Sequence, ) -from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable +from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable import httpx import pydantic @@ -195,7 +195,9 @@ def get(self, __key: str) -> str | None: ... # Note: copied from Pydantic # https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49 -IncEx: TypeAlias = "set[int] | set[str] | dict[int, Any] | dict[str, Any] | None" +IncEx: TypeAlias = Union[ + Set[int], Set[str], Mapping[int, Union["IncEx", Literal[True]]], Mapping[str, Union["IncEx", Literal[True]]] +] PostParser = Callable[[Any], Any] diff --git a/src/finch/types/account_update_event.py b/src/finch/types/account_update_event.py index 38dd0776..fe85887d 100644 --- a/src/finch/types/account_update_event.py +++ b/src/finch/types/account_update_event.py @@ -33,6 +33,7 @@ "AccountUpdateEventDataAuthenticationMethodSupportedFieldsIndividualEmails", "AccountUpdateEventDataAuthenticationMethodSupportedFieldsIndividualPhoneNumbers", "AccountUpdateEventDataAuthenticationMethodSupportedFieldsIndividualResidence", + "AccountUpdateEventDataAuthenticationMethodSupportedFieldsPayGroup", "AccountUpdateEventDataAuthenticationMethodSupportedFieldsPayStatement", "AccountUpdateEventDataAuthenticationMethodSupportedFieldsPayStatementPaging", "AccountUpdateEventDataAuthenticationMethodSupportedFieldsPayStatementPayStatements", @@ -263,6 +264,16 @@ class AccountUpdateEventDataAuthenticationMethodSupportedFieldsIndividual(BaseMo ssn: Optional[bool] = None +class AccountUpdateEventDataAuthenticationMethodSupportedFieldsPayGroup(BaseModel): + id: Optional[bool] = None + + individual_ids: Optional[bool] = None + + name: Optional[bool] = None + + pay_frequencies: Optional[bool] = None + + class AccountUpdateEventDataAuthenticationMethodSupportedFieldsPayStatementPaging(BaseModel): count: bool @@ -388,6 +399,8 @@ class AccountUpdateEventDataAuthenticationMethodSupportedFields(BaseModel): individual: Optional[AccountUpdateEventDataAuthenticationMethodSupportedFieldsIndividual] = None + pay_group: Optional[AccountUpdateEventDataAuthenticationMethodSupportedFieldsPayGroup] = None + pay_statement: Optional[AccountUpdateEventDataAuthenticationMethodSupportedFieldsPayStatement] = None payment: Optional[AccountUpdateEventDataAuthenticationMethodSupportedFieldsPayment] = None diff --git a/src/finch/types/provider.py b/src/finch/types/provider.py index d34b3acb..8e81f3a5 100644 --- a/src/finch/types/provider.py +++ b/src/finch/types/provider.py @@ -30,6 +30,7 @@ "AuthenticationMethodSupportedFieldsIndividualEmails", "AuthenticationMethodSupportedFieldsIndividualPhoneNumbers", "AuthenticationMethodSupportedFieldsIndividualResidence", + "AuthenticationMethodSupportedFieldsPayGroup", "AuthenticationMethodSupportedFieldsPayStatement", "AuthenticationMethodSupportedFieldsPayStatementPaging", "AuthenticationMethodSupportedFieldsPayStatementPayStatements", @@ -260,6 +261,16 @@ class AuthenticationMethodSupportedFieldsIndividual(BaseModel): ssn: Optional[bool] = None +class AuthenticationMethodSupportedFieldsPayGroup(BaseModel): + id: Optional[bool] = None + + individual_ids: Optional[bool] = None + + name: Optional[bool] = None + + pay_frequencies: Optional[bool] = None + + class AuthenticationMethodSupportedFieldsPayStatementPaging(BaseModel): count: bool @@ -379,6 +390,8 @@ class AuthenticationMethodSupportedFields(BaseModel): individual: Optional[AuthenticationMethodSupportedFieldsIndividual] = None + pay_group: Optional[AuthenticationMethodSupportedFieldsPayGroup] = None + pay_statement: Optional[AuthenticationMethodSupportedFieldsPayStatement] = None payment: Optional[AuthenticationMethodSupportedFieldsPayment] = None diff --git a/tests/conftest.py b/tests/conftest.py index 2c791d06..6736c763 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,11 +1,11 @@ from __future__ import annotations import os -import asyncio import logging from typing import TYPE_CHECKING, Iterator, AsyncIterator import pytest +from pytest_asyncio import is_async_test from finch import Finch, AsyncFinch @@ -17,11 +17,13 @@ logging.getLogger("finch").setLevel(logging.DEBUG) -@pytest.fixture(scope="session") -def event_loop() -> Iterator[asyncio.AbstractEventLoop]: - loop = asyncio.new_event_loop() - yield loop - loop.close() +# automatically add `pytest.mark.asyncio()` to all of our async tests +# so we don't have to add that boilerplate everywhere +def pytest_collection_modifyitems(items: list[pytest.Function]) -> None: + pytest_asyncio_tests = (item for item in items if is_async_test(item)) + session_scope_marker = pytest.mark.asyncio(loop_scope="session") + for async_test in pytest_asyncio_tests: + async_test.add_marker(session_scope_marker, append=False) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")