From 5fe6e56f670aa7e528171f567fbf8e6c2aa6a7e5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 24 Apr 2024 15:57:48 +0000 Subject: [PATCH 01/11] fix(docs): doc improvements (#359) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0587a6dc..3b2a8c06 100644 --- a/README.md +++ b/README.md @@ -338,7 +338,7 @@ The context manager is required so that the response will reliably be closed. ### Making custom/undocumented requests -This library is typed for convenient access the documented API. +This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used. From 278962a5e7a278b46c309fbc3a003568d7938ab6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 24 Apr 2024 20:40:46 +0000 Subject: [PATCH 02/11] chore(internal): use actions/checkout@v4 for codeflow (#361) --- .github/workflows/publish-pypi.yml | 2 +- .github/workflows/release-doctor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 3431733b..3c56474f 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Rye run: | diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 1bed94ad..8d4bb603 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -10,7 +10,7 @@ jobs: if: github.repository == 'Finch-API/finch-api-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Check release environment run: | From 5f9f330d00a95e390aa1f327afad354d97f0c52d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 03:38:20 +0000 Subject: [PATCH 03/11] chore(internal): update test helper function (#362) --- tests/utils.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/utils.py b/tests/utils.py index 7e3d3203..03639932 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -97,7 +97,22 @@ def assert_matches_type( assert_matches_type(key_type, key, path=[*path, ""]) assert_matches_type(items_type, item, path=[*path, ""]) elif is_union_type(type_): - for i, variant in enumerate(get_args(type_)): + variants = get_args(type_) + + try: + none_index = variants.index(type(None)) + except ValueError: + pass + else: + # special case Optional[T] for better error messages + if len(variants) == 2: + if value is None: + # valid + return + + return assert_matches_type(type_=variants[not none_index], value=value, path=path) + + for i, variant in enumerate(variants): try: assert_matches_type(variant, value, path=[*path, f"variant {i}"]) return From f10523a9fd09d306bc8405eea73311da8a9d8a3e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 22:43:39 +0000 Subject: [PATCH 04/11] docs: clarify behavior around employee_size (#363) --- src/finch/resources/sandbox/connections/connections.py | 6 ++++-- src/finch/types/sandbox/connection_create_params.py | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/finch/resources/sandbox/connections/connections.py b/src/finch/resources/sandbox/connections/connections.py index d8d34b85..682f3321 100644 --- a/src/finch/resources/sandbox/connections/connections.py +++ b/src/finch/resources/sandbox/connections/connections.py @@ -65,7 +65,8 @@ def create( Args: employee_size: Optional: the size of the employer to be created with this connection. Defaults - to 20 + to 20. Note that if this is higher than 100, historical payroll data will not be + generated, and instead only one pay period will be created. extra_headers: Send extra headers @@ -125,7 +126,8 @@ async def create( Args: employee_size: Optional: the size of the employer to be created with this connection. Defaults - to 20 + to 20. Note that if this is higher than 100, historical payroll data will not be + generated, and instead only one pay period will be created. extra_headers: Send extra headers diff --git a/src/finch/types/sandbox/connection_create_params.py b/src/finch/types/sandbox/connection_create_params.py index e7e7ce05..3c287302 100644 --- a/src/finch/types/sandbox/connection_create_params.py +++ b/src/finch/types/sandbox/connection_create_params.py @@ -16,7 +16,8 @@ class ConnectionCreateParams(TypedDict, total=False): employee_size: int """Optional: the size of the employer to be created with this connection. - Defaults to 20 + Defaults to 20. Note that if this is higher than 100, historical payroll data + will not be generated, and instead only one pay period will be created. """ products: List[str] From 62a5f983d0b099535ba06cb9f1ee2a9490d98314 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:48:52 +0000 Subject: [PATCH 05/11] chore(internal): reformat imports (#364) --- tests/api_resources/hris/benefits/test_individuals.py | 10 ++++++---- tests/api_resources/hris/test_benefits.py | 10 ++++++---- tests/api_resources/hris/test_company.py | 2 +- tests/api_resources/hris/test_directory.py | 2 +- tests/api_resources/hris/test_employments.py | 2 +- tests/api_resources/hris/test_individuals.py | 2 +- tests/api_resources/hris/test_pay_statements.py | 2 +- tests/api_resources/hris/test_payments.py | 2 +- tests/api_resources/jobs/test_automated.py | 3 +-- tests/api_resources/jobs/test_manual.py | 2 +- .../api_resources/sandbox/connections/test_accounts.py | 6 ++++-- tests/api_resources/sandbox/jobs/test_configuration.py | 3 +-- tests/api_resources/sandbox/test_company.py | 2 +- tests/api_resources/sandbox/test_connections.py | 2 +- tests/api_resources/sandbox/test_directory.py | 2 +- tests/api_resources/sandbox/test_employment.py | 2 +- tests/api_resources/sandbox/test_individual.py | 2 +- tests/api_resources/sandbox/test_jobs.py | 2 +- tests/api_resources/sandbox/test_payment.py | 2 +- tests/api_resources/test_access_tokens.py | 2 +- tests/api_resources/test_account.py | 3 +-- tests/api_resources/test_providers.py | 2 +- tests/api_resources/test_request_forwarding.py | 2 +- 23 files changed, 36 insertions(+), 33 deletions(-) diff --git a/tests/api_resources/hris/benefits/test_individuals.py b/tests/api_resources/hris/benefits/test_individuals.py index 252b12ed..9defbc96 100644 --- a/tests/api_resources/hris/benefits/test_individuals.py +++ b/tests/api_resources/hris/benefits/test_individuals.py @@ -10,10 +10,12 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type from finch.pagination import SyncSinglePage, AsyncSinglePage -from finch.types.hris.benefits.individual_benefit import IndividualBenefit -from finch.types.hris.benefits.enrolled_individual import EnrolledIndividual -from finch.types.hris.benefits.unenrolled_individual import UnenrolledIndividual -from finch.types.hris.benefits.individual_enrolled_ids_response import IndividualEnrolledIDsResponse +from finch.types.hris.benefits import ( + IndividualBenefit, + EnrolledIndividual, + UnenrolledIndividual, + IndividualEnrolledIDsResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/hris/test_benefits.py b/tests/api_resources/hris/test_benefits.py index 6be54989..ea02d4ac 100644 --- a/tests/api_resources/hris/test_benefits.py +++ b/tests/api_resources/hris/test_benefits.py @@ -10,10 +10,12 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type from finch.pagination import SyncSinglePage, AsyncSinglePage -from finch.types.hris.company_benefit import CompanyBenefit -from finch.types.hris.supported_benefit import SupportedBenefit -from finch.types.hris.update_company_benefit_response import UpdateCompanyBenefitResponse -from finch.types.hris.create_company_benefits_response import CreateCompanyBenefitsResponse +from finch.types.hris import ( + CompanyBenefit, + SupportedBenefit, + UpdateCompanyBenefitResponse, + CreateCompanyBenefitsResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/hris/test_company.py b/tests/api_resources/hris/test_company.py index 8ea9dba0..ea4052f9 100644 --- a/tests/api_resources/hris/test_company.py +++ b/tests/api_resources/hris/test_company.py @@ -9,7 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.hris.company import Company +from finch.types.hris import Company base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/hris/test_directory.py b/tests/api_resources/hris/test_directory.py index e8d9603b..5822d710 100644 --- a/tests/api_resources/hris/test_directory.py +++ b/tests/api_resources/hris/test_directory.py @@ -10,7 +10,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type from finch.pagination import SyncIndividualsPage, AsyncIndividualsPage -from finch.types.hris.individual_in_directory import IndividualInDirectory +from finch.types.hris import IndividualInDirectory # pyright: reportDeprecated=false diff --git a/tests/api_resources/hris/test_employments.py b/tests/api_resources/hris/test_employments.py index 433b8f5e..d228f309 100644 --- a/tests/api_resources/hris/test_employments.py +++ b/tests/api_resources/hris/test_employments.py @@ -10,7 +10,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type from finch.pagination import SyncResponsesPage, AsyncResponsesPage -from finch.types.hris.employment_data_response import EmploymentDataResponse +from finch.types.hris import EmploymentDataResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/hris/test_individuals.py b/tests/api_resources/hris/test_individuals.py index 6558eafe..f34d10fb 100644 --- a/tests/api_resources/hris/test_individuals.py +++ b/tests/api_resources/hris/test_individuals.py @@ -10,7 +10,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type from finch.pagination import SyncResponsesPage, AsyncResponsesPage -from finch.types.hris.individual_response import IndividualResponse +from finch.types.hris import IndividualResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/hris/test_pay_statements.py b/tests/api_resources/hris/test_pay_statements.py index 3d77abdf..b52cc2b7 100644 --- a/tests/api_resources/hris/test_pay_statements.py +++ b/tests/api_resources/hris/test_pay_statements.py @@ -10,7 +10,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type from finch.pagination import SyncResponsesPage, AsyncResponsesPage -from finch.types.hris.pay_statement_response import PayStatementResponse +from finch.types.hris import PayStatementResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/hris/test_payments.py b/tests/api_resources/hris/test_payments.py index 4d421368..70b183ea 100644 --- a/tests/api_resources/hris/test_payments.py +++ b/tests/api_resources/hris/test_payments.py @@ -11,7 +11,7 @@ from tests.utils import assert_matches_type from finch._utils import parse_date from finch.pagination import SyncSinglePage, AsyncSinglePage -from finch.types.hris.payment import Payment +from finch.types.hris import Payment base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/jobs/test_automated.py b/tests/api_resources/jobs/test_automated.py index 632d4051..5cf5644a 100644 --- a/tests/api_resources/jobs/test_automated.py +++ b/tests/api_resources/jobs/test_automated.py @@ -10,8 +10,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type from finch.pagination import SyncPage, AsyncPage -from finch.types.jobs.automated_async_job import AutomatedAsyncJob -from finch.types.jobs.automated_create_response import AutomatedCreateResponse +from finch.types.jobs import AutomatedAsyncJob, AutomatedCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/jobs/test_manual.py b/tests/api_resources/jobs/test_manual.py index 71d2cc4a..ec6d528a 100644 --- a/tests/api_resources/jobs/test_manual.py +++ b/tests/api_resources/jobs/test_manual.py @@ -9,7 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.jobs.manual_async_job import ManualAsyncJob +from finch.types.jobs import ManualAsyncJob base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/sandbox/connections/test_accounts.py b/tests/api_resources/sandbox/connections/test_accounts.py index 16dfd79e..82058694 100644 --- a/tests/api_resources/sandbox/connections/test_accounts.py +++ b/tests/api_resources/sandbox/connections/test_accounts.py @@ -9,8 +9,10 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.sandbox.connections.account_create_response import AccountCreateResponse -from finch.types.sandbox.connections.account_update_response import AccountUpdateResponse +from finch.types.sandbox.connections import ( + AccountCreateResponse, + AccountUpdateResponse, +) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/sandbox/jobs/test_configuration.py b/tests/api_resources/sandbox/jobs/test_configuration.py index 34503f42..b7d8ac2c 100644 --- a/tests/api_resources/sandbox/jobs/test_configuration.py +++ b/tests/api_resources/sandbox/jobs/test_configuration.py @@ -9,8 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.sandbox.jobs.sandbox_job_configuration import SandboxJobConfiguration -from finch.types.sandbox.jobs.configuration_retrieve_response import ConfigurationRetrieveResponse +from finch.types.sandbox.jobs import SandboxJobConfiguration, ConfigurationRetrieveResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/sandbox/test_company.py b/tests/api_resources/sandbox/test_company.py index c1d549a1..4104eb8a 100644 --- a/tests/api_resources/sandbox/test_company.py +++ b/tests/api_resources/sandbox/test_company.py @@ -9,7 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.sandbox.company_update_response import CompanyUpdateResponse +from finch.types.sandbox import CompanyUpdateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/sandbox/test_connections.py b/tests/api_resources/sandbox/test_connections.py index e7590976..2cbb0fe0 100644 --- a/tests/api_resources/sandbox/test_connections.py +++ b/tests/api_resources/sandbox/test_connections.py @@ -9,7 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.sandbox.connection_create_response import ConnectionCreateResponse +from finch.types.sandbox import ConnectionCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/sandbox/test_directory.py b/tests/api_resources/sandbox/test_directory.py index 65a1644c..a42d4fcb 100644 --- a/tests/api_resources/sandbox/test_directory.py +++ b/tests/api_resources/sandbox/test_directory.py @@ -9,7 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.sandbox.directory_create_response import DirectoryCreateResponse +from finch.types.sandbox import DirectoryCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/sandbox/test_employment.py b/tests/api_resources/sandbox/test_employment.py index 59d8d2d1..7183dac5 100644 --- a/tests/api_resources/sandbox/test_employment.py +++ b/tests/api_resources/sandbox/test_employment.py @@ -9,7 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.sandbox.employment_update_response import EmploymentUpdateResponse +from finch.types.sandbox import EmploymentUpdateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/sandbox/test_individual.py b/tests/api_resources/sandbox/test_individual.py index bcce58fc..5d8f0683 100644 --- a/tests/api_resources/sandbox/test_individual.py +++ b/tests/api_resources/sandbox/test_individual.py @@ -9,7 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.sandbox.individual_update_response import IndividualUpdateResponse +from finch.types.sandbox import IndividualUpdateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/sandbox/test_jobs.py b/tests/api_resources/sandbox/test_jobs.py index 33d105cb..fd990987 100644 --- a/tests/api_resources/sandbox/test_jobs.py +++ b/tests/api_resources/sandbox/test_jobs.py @@ -9,7 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.sandbox.job_create_response import JobCreateResponse +from finch.types.sandbox import JobCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/sandbox/test_payment.py b/tests/api_resources/sandbox/test_payment.py index 39bb7873..9b0c803a 100644 --- a/tests/api_resources/sandbox/test_payment.py +++ b/tests/api_resources/sandbox/test_payment.py @@ -9,7 +9,7 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch.types.sandbox.payment_create_response import PaymentCreateResponse +from finch.types.sandbox import PaymentCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/test_access_tokens.py b/tests/api_resources/test_access_tokens.py index 3b5da120..3dcbe2e3 100644 --- a/tests/api_resources/test_access_tokens.py +++ b/tests/api_resources/test_access_tokens.py @@ -8,8 +8,8 @@ import pytest from finch import Finch, AsyncFinch +from finch.types import CreateAccessTokenResponse from tests.utils import assert_matches_type -from finch.types.create_access_token_response import CreateAccessTokenResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/test_account.py b/tests/api_resources/test_account.py index 5addd4b6..2464a527 100644 --- a/tests/api_resources/test_account.py +++ b/tests/api_resources/test_account.py @@ -8,9 +8,8 @@ import pytest from finch import Finch, AsyncFinch +from finch.types import Introspection, DisconnectResponse from tests.utils import assert_matches_type -from finch.types.introspection import Introspection -from finch.types.disconnect_response import DisconnectResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/test_providers.py b/tests/api_resources/test_providers.py index 4985d486..380fdf9c 100644 --- a/tests/api_resources/test_providers.py +++ b/tests/api_resources/test_providers.py @@ -8,9 +8,9 @@ import pytest from finch import Finch, AsyncFinch +from finch.types import Provider from tests.utils import assert_matches_type from finch.pagination import SyncSinglePage, AsyncSinglePage -from finch.types.provider import Provider base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") diff --git a/tests/api_resources/test_request_forwarding.py b/tests/api_resources/test_request_forwarding.py index 0a1758f5..ea0c6319 100644 --- a/tests/api_resources/test_request_forwarding.py +++ b/tests/api_resources/test_request_forwarding.py @@ -8,8 +8,8 @@ import pytest from finch import Finch, AsyncFinch +from finch.types import RequestForwardingForwardResponse from tests.utils import assert_matches_type -from finch.types.request_forwarding_forward_response import RequestForwardingForwardResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") From a7253edc76bad52f14d2c1f0fb876077b30128a9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:48:09 +0000 Subject: [PATCH 06/11] chore(internal): minor reformatting (#365) --- src/finch/types/base_webhook_event.py | 2 ++ src/finch/types/disconnect_response.py | 2 ++ src/finch/types/hris/create_company_benefits_response.py | 2 ++ src/finch/types/hris/update_company_benefit_response.py | 2 ++ src/finch/types/jobs/automated_create_response.py | 2 ++ src/finch/types/sandbox/job_create_response.py | 2 ++ src/finch/types/sandbox/payment_create_response.py | 2 ++ tests/test_client.py | 1 - 8 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/finch/types/base_webhook_event.py b/src/finch/types/base_webhook_event.py index 2b9561d1..87bd216a 100644 --- a/src/finch/types/base_webhook_event.py +++ b/src/finch/types/base_webhook_event.py @@ -1,5 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + from .._models import BaseModel __all__ = ["BaseWebhookEvent"] diff --git a/src/finch/types/disconnect_response.py b/src/finch/types/disconnect_response.py index 2d128175..d30ec36c 100644 --- a/src/finch/types/disconnect_response.py +++ b/src/finch/types/disconnect_response.py @@ -1,5 +1,7 @@ # 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/create_company_benefits_response.py b/src/finch/types/hris/create_company_benefits_response.py index 9e5ff39b..105cec00 100644 --- a/src/finch/types/hris/create_company_benefits_response.py +++ b/src/finch/types/hris/create_company_benefits_response.py @@ -1,5 +1,7 @@ # 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 29faf7b4..9cc7e992 100644 --- a/src/finch/types/hris/update_company_benefit_response.py +++ b/src/finch/types/hris/update_company_benefit_response.py @@ -1,5 +1,7 @@ # 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 9d53fb1c..cb3159b9 100644 --- a/src/finch/types/jobs/automated_create_response.py +++ b/src/finch/types/jobs/automated_create_response.py @@ -1,5 +1,7 @@ # 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 0c085dfc..80bc795d 100644 --- a/src/finch/types/sandbox/job_create_response.py +++ b/src/finch/types/sandbox/job_create_response.py @@ -1,5 +1,7 @@ # 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 17cdaa8a..6b31d415 100644 --- a/src/finch/types/sandbox/payment_create_response.py +++ b/src/finch/types/sandbox/payment_create_response.py @@ -1,5 +1,7 @@ # 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 0995ec32..6585e9e3 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -18,7 +18,6 @@ from finch import Finch, AsyncFinch, APIResponseValidationError from finch._types import Omit -from finch._client import Finch, AsyncFinch from finch._models import BaseModel, FinalRequestOptions from finch._exceptions import APIResponseValidationError from finch._base_client import DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, make_request_options From 5dcc0e5d62b6f334ca73c401dd4ce5e21dcb2d96 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:29:21 +0000 Subject: [PATCH 07/11] chore(client): log response headers in debug mode (#366) --- src/finch/_base_client.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/finch/_base_client.py b/src/finch/_base_client.py index fc1fedb7..128e20d2 100644 --- a/src/finch/_base_client.py +++ b/src/finch/_base_client.py @@ -946,6 +946,8 @@ def _request( if self.custom_auth is not None: kwargs["auth"] = self.custom_auth + log.debug("Sending HTTP Request: %s %s", request.method, request.url) + try: response = self._client.send( request, @@ -984,7 +986,12 @@ def _request( raise APIConnectionError(request=request) from err log.debug( - 'HTTP Request: %s %s "%i %s"', request.method, request.url, response.status_code, response.reason_phrase + 'HTTP Response: %s %s "%i %s" %s', + request.method, + request.url, + response.status_code, + response.reason_phrase, + response.headers, ) try: From 378727a8d21c89384d82a99dfcf64ac0091fcd84 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 17:05:31 +0000 Subject: [PATCH 08/11] chore(internal): add link to openapi spec (#367) --- .stats.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.stats.yml b/.stats.yml index 397ee0a4..72c3e9f8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1,2 @@ configured_endpoints: 35 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch-a14d8915465614a275f05ccb91513576fab0525b488cb878dbe3d692f5b2349f.yml From ff132d5dca28c4910c6eaa9f6484d93b770bbffd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 22:17:54 +0000 Subject: [PATCH 09/11] chore(internal): add scripts/test, scripts/mock and add ci job (#368) --- .github/workflows/ci.yml | 22 ++++++++++- .gitignore | 1 + Brewfile | 2 + bin/check-env-state.py | 40 ------------------- bin/check-test-server | 50 ----------------------- bin/test | 3 -- pyproject.toml | 3 +- scripts/bootstrap | 19 +++++++++ scripts/format | 8 ++++ scripts/lint | 8 ++++ scripts/mock | 41 +++++++++++++++++++ scripts/test | 57 +++++++++++++++++++++++++++ {bin => scripts/utils}/ruffen-docs.py | 0 13 files changed, 159 insertions(+), 95 deletions(-) create mode 100644 Brewfile delete mode 100644 bin/check-env-state.py delete mode 100755 bin/check-test-server delete mode 100755 bin/test create mode 100755 scripts/bootstrap create mode 100755 scripts/format create mode 100755 scripts/lint create mode 100755 scripts/mock create mode 100755 scripts/test rename {bin => scripts/utils}/ruffen-docs.py (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7af0200..174c3b11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,5 +39,25 @@ jobs: - name: Ensure importable run: | rye run python -c 'import finch' + test: + name: test + runs-on: ubuntu-latest + if: github.repository == 'Finch-API/finch-api-python' + + steps: + - uses: actions/checkout@v4 + + - name: Install Rye + run: | + curl -sSf https://rye-up.com/get | bash + echo "$HOME/.rye/shims" >> $GITHUB_PATH + env: + RYE_VERSION: 0.24.0 + RYE_INSTALL_OPTION: '--yes' + + - name: Bootstrap + run: ./scripts/bootstrap + + - name: Run tests + run: ./scripts/test - diff --git a/.gitignore b/.gitignore index a4b2f8c0..0f9a66a9 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ dist .env .envrc codegen.log +Brewfile.lock.json diff --git a/Brewfile b/Brewfile new file mode 100644 index 00000000..492ca37b --- /dev/null +++ b/Brewfile @@ -0,0 +1,2 @@ +brew "rye" + diff --git a/bin/check-env-state.py b/bin/check-env-state.py deleted file mode 100644 index e1b8b6cb..00000000 --- a/bin/check-env-state.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Script that exits 1 if the current environment is not -in sync with the `requirements-dev.lock` file. -""" - -from pathlib import Path - -import importlib_metadata - - -def should_run_sync() -> bool: - dev_lock = Path(__file__).parent.parent.joinpath("requirements-dev.lock") - - for line in dev_lock.read_text().splitlines(): - if not line or line.startswith("#") or line.startswith("-e"): - continue - - dep, lock_version = line.split("==") - - try: - version = importlib_metadata.version(dep) - - if lock_version != version: - print(f"mismatch for {dep} current={version} lock={lock_version}") - return True - except Exception: - print(f"could not import {dep}") - return True - - return False - - -def main() -> None: - if should_run_sync(): - exit(1) - else: - exit(0) - - -if __name__ == "__main__": - main() diff --git a/bin/check-test-server b/bin/check-test-server deleted file mode 100755 index a6fa3495..00000000 --- a/bin/check-test-server +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash - -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color - -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if is_overriding_api_base_url ; then - # If someone is running the tests against the live API, we can trust they know - # what they're doing and exit early. - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - - exit 0 -elif prism_is_running ; then - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo - - exit 0 -else - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "${YELLOW}To fix:${NC}" - echo - echo -e "1. Install Prism (requires Node 16+):" - echo - echo -e " With npm:" - echo -e " \$ ${YELLOW}npm install -g @stoplight/prism-cli${NC}" - echo - echo -e " With yarn:" - echo -e " \$ ${YELLOW}yarn global add @stoplight/prism-cli${NC}" - echo - echo -e "2. Run the mock server" - echo - echo -e " To run the server, pass in the path of your OpenAPI" - echo -e " spec to the prism command:" - echo - echo -e " \$ ${YELLOW}prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -fi diff --git a/bin/test b/bin/test deleted file mode 100755 index 60ede7a8..00000000 --- a/bin/test +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -bin/check-test-server && rye run pytest "$@" diff --git a/pyproject.toml b/pyproject.toml index a4fe9a20..e3241a38 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ format = { chain = [ "fix:ruff", ]} "format:black" = "black ." -"format:docs" = "python bin/ruffen-docs.py README.md api.md" +"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md" "format:ruff" = "ruff format" "format:isort" = "isort ." @@ -191,5 +191,6 @@ known-first-party = ["finch", "tests"] [tool.ruff.per-file-ignores] "bin/**.py" = ["T201", "T203"] +"scripts/**.py" = ["T201", "T203"] "tests/**.py" = ["T201", "T203"] "examples/**.py" = ["T201", "T203"] diff --git a/scripts/bootstrap b/scripts/bootstrap new file mode 100755 index 00000000..29df07e7 --- /dev/null +++ b/scripts/bootstrap @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then + brew bundle check >/dev/null 2>&1 || { + echo "==> Installing Homebrew dependencies…" + brew bundle + } +fi + +echo "==> Installing Python dependencies…" + +# experimental uv support makes installations significantly faster +rye config --set-bool behavior.use-uv=true + +rye sync diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..2a9ea466 --- /dev/null +++ b/scripts/format @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +rye run format + diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..0cc68b51 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +rye run lint + diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 00000000..5a8c35b7 --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..be01d044 --- /dev/null +++ b/scripts/test @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +# Run tests +echo "==> Running tests" +rye run pytest "$@" diff --git a/bin/ruffen-docs.py b/scripts/utils/ruffen-docs.py similarity index 100% rename from bin/ruffen-docs.py rename to scripts/utils/ruffen-docs.py From ad0b12e37c5c05876cae92cf474a5fd70ad52689 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 17:48:36 +0000 Subject: [PATCH 10/11] chore(internal): bump mock server version to ~5.8.0 (#369) --- scripts/mock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mock b/scripts/mock index 5a8c35b7..fe89a1d0 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock "$URL" + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" fi From 8a88d636ab7efb935978372231ef60d9fba417d7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 17:48:52 +0000 Subject: [PATCH 11/11] release: 0.20.3 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 25 +++++++++++++++++++++++++ pyproject.toml | 2 +- src/finch/_version.py | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 0b06fef6..bba0c295 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.20.2" + ".": "0.20.3" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a9d898d..2019bdef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +## 0.20.3 (2024-05-01) + +Full Changelog: [v0.20.2...v0.20.3](https://github.com/Finch-API/finch-api-python/compare/v0.20.2...v0.20.3) + +### Bug Fixes + +* **docs:** doc improvements ([#359](https://github.com/Finch-API/finch-api-python/issues/359)) ([5fe6e56](https://github.com/Finch-API/finch-api-python/commit/5fe6e56f670aa7e528171f567fbf8e6c2aa6a7e5)) + + +### Chores + +* **client:** log response headers in debug mode ([#366](https://github.com/Finch-API/finch-api-python/issues/366)) ([5dcc0e5](https://github.com/Finch-API/finch-api-python/commit/5dcc0e5d62b6f334ca73c401dd4ce5e21dcb2d96)) +* **internal:** add link to openapi spec ([#367](https://github.com/Finch-API/finch-api-python/issues/367)) ([378727a](https://github.com/Finch-API/finch-api-python/commit/378727a8d21c89384d82a99dfcf64ac0091fcd84)) +* **internal:** add scripts/test, scripts/mock and add ci job ([#368](https://github.com/Finch-API/finch-api-python/issues/368)) ([ff132d5](https://github.com/Finch-API/finch-api-python/commit/ff132d5dca28c4910c6eaa9f6484d93b770bbffd)) +* **internal:** bump mock server version to ~5.8.0 ([#369](https://github.com/Finch-API/finch-api-python/issues/369)) ([ad0b12e](https://github.com/Finch-API/finch-api-python/commit/ad0b12e37c5c05876cae92cf474a5fd70ad52689)) +* **internal:** minor reformatting ([#365](https://github.com/Finch-API/finch-api-python/issues/365)) ([a7253ed](https://github.com/Finch-API/finch-api-python/commit/a7253edc76bad52f14d2c1f0fb876077b30128a9)) +* **internal:** reformat imports ([#364](https://github.com/Finch-API/finch-api-python/issues/364)) ([62a5f98](https://github.com/Finch-API/finch-api-python/commit/62a5f983d0b099535ba06cb9f1ee2a9490d98314)) +* **internal:** update test helper function ([#362](https://github.com/Finch-API/finch-api-python/issues/362)) ([5f9f330](https://github.com/Finch-API/finch-api-python/commit/5f9f330d00a95e390aa1f327afad354d97f0c52d)) +* **internal:** use actions/checkout@v4 for codeflow ([#361](https://github.com/Finch-API/finch-api-python/issues/361)) ([278962a](https://github.com/Finch-API/finch-api-python/commit/278962a5e7a278b46c309fbc3a003568d7938ab6)) + + +### Documentation + +* clarify behavior around employee_size ([#363](https://github.com/Finch-API/finch-api-python/issues/363)) ([f10523a](https://github.com/Finch-API/finch-api-python/commit/f10523a9fd09d306bc8405eea73311da8a9d8a3e)) + ## 0.20.2 (2024-04-23) Full Changelog: [v0.20.1...v0.20.2](https://github.com/Finch-API/finch-api-python/compare/v0.20.1...v0.20.2) diff --git a/pyproject.toml b/pyproject.toml index e3241a38..e5eb015d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "finch-api" -version = "0.20.2" +version = "0.20.3" description = "The official Python library for the Finch API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/finch/_version.py b/src/finch/_version.py index fda4b3e6..c1053e8c 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__ = "0.20.2" # x-release-please-version +__version__ = "0.20.3" # x-release-please-version