Skip to content

feat(client): allow passing NotGiven for body #600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/finch/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def _build_request(
# so that passing a `TypedDict` doesn't cause an error.
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
json=json_data,
json=json_data if is_given(json_data) else None,
files=files,
**kwargs,
)
Expand Down
4 changes: 2 additions & 2 deletions src/finch/resources/hris/benefits/individuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def enroll_many(
self,
benefit_id: str,
*,
individuals: Iterable[individual_enroll_many_params.Individual],
individuals: Iterable[individual_enroll_many_params.Individual] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -234,7 +234,7 @@ def enroll_many(
self,
benefit_id: str,
*,
individuals: Iterable[individual_enroll_many_params.Individual],
individuals: Iterable[individual_enroll_many_params.Individual] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
4 changes: 2 additions & 2 deletions src/finch/resources/sandbox/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def with_streaming_response(self) -> DirectoryWithStreamingResponse:
def create(
self,
*,
body: Iterable[directory_create_params.Body],
body: Iterable[directory_create_params.Body] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -101,7 +101,7 @@ def with_streaming_response(self) -> AsyncDirectoryWithStreamingResponse:
async def create(
self,
*,
body: Iterable[directory_create_params.Body],
body: Iterable[directory_create_params.Body] | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from typing import Iterable, Optional
from typing_extensions import Literal, Required, TypedDict
from typing_extensions import Literal, TypedDict

__all__ = [
"IndividualEnrollManyParams",
Expand All @@ -15,7 +15,7 @@


class IndividualEnrollManyParams(TypedDict, total=False):
individuals: Required[Iterable[Individual]]
individuals: Iterable[Individual]
"""Array of the individual_id to enroll and a configuration object."""


Expand Down
4 changes: 2 additions & 2 deletions src/finch/types/sandbox/directory_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

from typing import Iterable, Optional
from typing_extensions import Literal, Required, TypedDict
from typing_extensions import Literal, TypedDict

from ..income_param import IncomeParam
from ..location_param import LocationParam
Expand All @@ -21,7 +21,7 @@


class DirectoryCreateParams(TypedDict, total=False):
body: Required[Iterable[Body]]
body: Iterable[Body]
"""Array of individuals to create.

Takes all combined fields from `/individual` and `/employment` endpoints. All
Expand Down
58 changes: 50 additions & 8 deletions tests/api_resources/hris/benefits/test_individuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,38 @@ class TestIndividuals:
def test_method_enroll_many(self, client: Finch) -> None:
individual = client.hris.benefits.individuals.enroll_many(
benefit_id="benefit_id",
individuals=[{}],
)
assert_matches_type(SyncSinglePage[EnrolledIndividual], individual, path=["response"])

@parametrize
def test_method_enroll_many_with_all_params(self, client: Finch) -> None:
individual = client.hris.benefits.individuals.enroll_many(
benefit_id="benefit_id",
individuals=[
{
"configuration": {
"annual_contribution_limit": "individual",
"annual_maximum": 500000,
"catch_up": False,
"company_contribution": {
"amount": 400,
"type": "fixed",
},
"employee_deduction": {
"amount": 1000,
"type": "fixed",
},
},
"individual_id": "d02a6346-1f08-4312-a064-49ff3cafaa7a",
}
],
)
assert_matches_type(SyncSinglePage[EnrolledIndividual], individual, path=["response"])

@parametrize
def test_raw_response_enroll_many(self, client: Finch) -> None:
response = client.hris.benefits.individuals.with_raw_response.enroll_many(
benefit_id="benefit_id",
individuals=[{}],
)

assert response.is_closed is True
Expand All @@ -47,7 +70,6 @@ def test_raw_response_enroll_many(self, client: Finch) -> None:
def test_streaming_response_enroll_many(self, client: Finch) -> None:
with client.hris.benefits.individuals.with_streaming_response.enroll_many(
benefit_id="benefit_id",
individuals=[{}],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -62,7 +84,6 @@ def test_path_params_enroll_many(self, client: Finch) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `benefit_id` but received ''"):
client.hris.benefits.individuals.with_raw_response.enroll_many(
benefit_id="",
individuals=[{}],
)

@parametrize
Expand Down Expand Up @@ -203,15 +224,38 @@ class TestAsyncIndividuals:
async def test_method_enroll_many(self, async_client: AsyncFinch) -> None:
individual = await async_client.hris.benefits.individuals.enroll_many(
benefit_id="benefit_id",
individuals=[{}],
)
assert_matches_type(AsyncSinglePage[EnrolledIndividual], individual, path=["response"])

@parametrize
async def test_method_enroll_many_with_all_params(self, async_client: AsyncFinch) -> None:
individual = await async_client.hris.benefits.individuals.enroll_many(
benefit_id="benefit_id",
individuals=[
{
"configuration": {
"annual_contribution_limit": "individual",
"annual_maximum": 500000,
"catch_up": False,
"company_contribution": {
"amount": 400,
"type": "fixed",
},
"employee_deduction": {
"amount": 1000,
"type": "fixed",
},
},
"individual_id": "d02a6346-1f08-4312-a064-49ff3cafaa7a",
}
],
)
assert_matches_type(AsyncSinglePage[EnrolledIndividual], individual, path=["response"])

@parametrize
async def test_raw_response_enroll_many(self, async_client: AsyncFinch) -> None:
response = await async_client.hris.benefits.individuals.with_raw_response.enroll_many(
benefit_id="benefit_id",
individuals=[{}],
)

assert response.is_closed is True
Expand All @@ -223,7 +267,6 @@ async def test_raw_response_enroll_many(self, async_client: AsyncFinch) -> None:
async def test_streaming_response_enroll_many(self, async_client: AsyncFinch) -> None:
async with async_client.hris.benefits.individuals.with_streaming_response.enroll_many(
benefit_id="benefit_id",
individuals=[{}],
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -238,7 +281,6 @@ async def test_path_params_enroll_many(self, async_client: AsyncFinch) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `benefit_id` but received ''"):
await async_client.hris.benefits.individuals.with_raw_response.enroll_many(
benefit_id="",
individuals=[{}],
)

@parametrize
Expand Down
Loading