From cababd656bcc34c68419a4d00812965f92e0fa5c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 16 Dec 2025 04:26:37 +0000 Subject: [PATCH 1/5] chore(internal): add missing files argument to base client --- src/brapi/_base_client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/brapi/_base_client.py b/src/brapi/_base_client.py index 2c643d3..ac40494 100644 --- a/src/brapi/_base_client.py +++ b/src/brapi/_base_client.py @@ -1247,9 +1247,12 @@ def patch( *, cast_to: Type[ResponseT], body: Body | None = None, + files: RequestFiles | None = None, options: RequestOptions = {}, ) -> ResponseT: - opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options) + opts = FinalRequestOptions.construct( + method="patch", url=path, json_data=body, files=to_httpx_files(files), **options + ) return self.request(cast_to, opts) def put( @@ -1767,9 +1770,12 @@ async def patch( *, cast_to: Type[ResponseT], body: Body | None = None, + files: RequestFiles | None = None, options: RequestOptions = {}, ) -> ResponseT: - opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options) + opts = FinalRequestOptions.construct( + method="patch", url=path, json_data=body, files=to_httpx_files(files), **options + ) return await self.request(cast_to, opts) async def put( From 7261e025f7cf5448c964892296d7c54999926cdd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 05:59:26 +0000 Subject: [PATCH 2/5] chore: speedup initial import --- src/brapi/_client.py | 179 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 142 insertions(+), 37 deletions(-) diff --git a/src/brapi/_client.py b/src/brapi/_client.py index 992de0c..80b62ff 100644 --- a/src/brapi/_client.py +++ b/src/brapi/_client.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Dict, Mapping, cast +from typing import TYPE_CHECKING, Any, Dict, Mapping, cast from typing_extensions import Self, Literal, override import httpx @@ -20,8 +20,8 @@ not_given, ) from ._utils import is_given, get_async_library +from ._compat import cached_property from ._version import __version__ -from .resources import quote, available from ._streaming import Stream as Stream, AsyncStream as AsyncStream from ._exceptions import BrapiError, APIStatusError from ._base_client import ( @@ -29,7 +29,12 @@ SyncAPIClient, AsyncAPIClient, ) -from .resources.v2 import v2 + +if TYPE_CHECKING: + from .resources import v2, quote, available + from .resources.quote import QuoteResource, AsyncQuoteResource + from .resources.v2.v2 import V2Resource, AsyncV2Resource + from .resources.available import AvailableResource, AsyncAvailableResource __all__ = [ "ENVIRONMENTS", @@ -50,12 +55,6 @@ class Brapi(SyncAPIClient): - quote: quote.QuoteResource - available: available.AvailableResource - v2: v2.V2Resource - with_raw_response: BrapiWithRawResponse - with_streaming_response: BrapiWithStreamedResponse - # client options api_key: str @@ -134,11 +133,31 @@ def __init__( _strict_response_validation=_strict_response_validation, ) - self.quote = quote.QuoteResource(self) - self.available = available.AvailableResource(self) - self.v2 = v2.V2Resource(self) - self.with_raw_response = BrapiWithRawResponse(self) - self.with_streaming_response = BrapiWithStreamedResponse(self) + @cached_property + def quote(self) -> QuoteResource: + from .resources.quote import QuoteResource + + return QuoteResource(self) + + @cached_property + def available(self) -> AvailableResource: + from .resources.available import AvailableResource + + return AvailableResource(self) + + @cached_property + def v2(self) -> V2Resource: + from .resources.v2 import V2Resource + + return V2Resource(self) + + @cached_property + def with_raw_response(self) -> BrapiWithRawResponse: + return BrapiWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BrapiWithStreamedResponse: + return BrapiWithStreamedResponse(self) @property @override @@ -248,12 +267,6 @@ def _make_status_error( class AsyncBrapi(AsyncAPIClient): - quote: quote.AsyncQuoteResource - available: available.AsyncAvailableResource - v2: v2.AsyncV2Resource - with_raw_response: AsyncBrapiWithRawResponse - with_streaming_response: AsyncBrapiWithStreamedResponse - # client options api_key: str @@ -332,11 +345,31 @@ def __init__( _strict_response_validation=_strict_response_validation, ) - self.quote = quote.AsyncQuoteResource(self) - self.available = available.AsyncAvailableResource(self) - self.v2 = v2.AsyncV2Resource(self) - self.with_raw_response = AsyncBrapiWithRawResponse(self) - self.with_streaming_response = AsyncBrapiWithStreamedResponse(self) + @cached_property + def quote(self) -> AsyncQuoteResource: + from .resources.quote import AsyncQuoteResource + + return AsyncQuoteResource(self) + + @cached_property + def available(self) -> AsyncAvailableResource: + from .resources.available import AsyncAvailableResource + + return AsyncAvailableResource(self) + + @cached_property + def v2(self) -> AsyncV2Resource: + from .resources.v2 import AsyncV2Resource + + return AsyncV2Resource(self) + + @cached_property + def with_raw_response(self) -> AsyncBrapiWithRawResponse: + return AsyncBrapiWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBrapiWithStreamedResponse: + return AsyncBrapiWithStreamedResponse(self) @property @override @@ -446,31 +479,103 @@ def _make_status_error( class BrapiWithRawResponse: + _client: Brapi + def __init__(self, client: Brapi) -> None: - self.quote = quote.QuoteResourceWithRawResponse(client.quote) - self.available = available.AvailableResourceWithRawResponse(client.available) - self.v2 = v2.V2ResourceWithRawResponse(client.v2) + self._client = client + + @cached_property + def quote(self) -> quote.QuoteResourceWithRawResponse: + from .resources.quote import QuoteResourceWithRawResponse + + return QuoteResourceWithRawResponse(self._client.quote) + + @cached_property + def available(self) -> available.AvailableResourceWithRawResponse: + from .resources.available import AvailableResourceWithRawResponse + + return AvailableResourceWithRawResponse(self._client.available) + + @cached_property + def v2(self) -> v2.V2ResourceWithRawResponse: + from .resources.v2 import V2ResourceWithRawResponse + + return V2ResourceWithRawResponse(self._client.v2) class AsyncBrapiWithRawResponse: + _client: AsyncBrapi + def __init__(self, client: AsyncBrapi) -> None: - self.quote = quote.AsyncQuoteResourceWithRawResponse(client.quote) - self.available = available.AsyncAvailableResourceWithRawResponse(client.available) - self.v2 = v2.AsyncV2ResourceWithRawResponse(client.v2) + self._client = client + + @cached_property + def quote(self) -> quote.AsyncQuoteResourceWithRawResponse: + from .resources.quote import AsyncQuoteResourceWithRawResponse + + return AsyncQuoteResourceWithRawResponse(self._client.quote) + + @cached_property + def available(self) -> available.AsyncAvailableResourceWithRawResponse: + from .resources.available import AsyncAvailableResourceWithRawResponse + + return AsyncAvailableResourceWithRawResponse(self._client.available) + + @cached_property + def v2(self) -> v2.AsyncV2ResourceWithRawResponse: + from .resources.v2 import AsyncV2ResourceWithRawResponse + + return AsyncV2ResourceWithRawResponse(self._client.v2) class BrapiWithStreamedResponse: + _client: Brapi + def __init__(self, client: Brapi) -> None: - self.quote = quote.QuoteResourceWithStreamingResponse(client.quote) - self.available = available.AvailableResourceWithStreamingResponse(client.available) - self.v2 = v2.V2ResourceWithStreamingResponse(client.v2) + self._client = client + + @cached_property + def quote(self) -> quote.QuoteResourceWithStreamingResponse: + from .resources.quote import QuoteResourceWithStreamingResponse + + return QuoteResourceWithStreamingResponse(self._client.quote) + + @cached_property + def available(self) -> available.AvailableResourceWithStreamingResponse: + from .resources.available import AvailableResourceWithStreamingResponse + + return AvailableResourceWithStreamingResponse(self._client.available) + + @cached_property + def v2(self) -> v2.V2ResourceWithStreamingResponse: + from .resources.v2 import V2ResourceWithStreamingResponse + + return V2ResourceWithStreamingResponse(self._client.v2) class AsyncBrapiWithStreamedResponse: + _client: AsyncBrapi + def __init__(self, client: AsyncBrapi) -> None: - self.quote = quote.AsyncQuoteResourceWithStreamingResponse(client.quote) - self.available = available.AsyncAvailableResourceWithStreamingResponse(client.available) - self.v2 = v2.AsyncV2ResourceWithStreamingResponse(client.v2) + self._client = client + + @cached_property + def quote(self) -> quote.AsyncQuoteResourceWithStreamingResponse: + from .resources.quote import AsyncQuoteResourceWithStreamingResponse + + return AsyncQuoteResourceWithStreamingResponse(self._client.quote) + + @cached_property + def available(self) -> available.AsyncAvailableResourceWithStreamingResponse: + from .resources.available import AsyncAvailableResourceWithStreamingResponse + + return AsyncAvailableResourceWithStreamingResponse(self._client.available) + + @cached_property + def v2(self) -> v2.AsyncV2ResourceWithStreamingResponse: + from .resources.v2 import AsyncV2ResourceWithStreamingResponse + + return AsyncV2ResourceWithStreamingResponse(self._client.v2) Client = Brapi From a0612291f12c3dbc71faab50d3beb93848801db3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 18 Dec 2025 06:49:08 +0000 Subject: [PATCH 3/5] fix: use async_to_httpx_files in patch method --- src/brapi/_base_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brapi/_base_client.py b/src/brapi/_base_client.py index ac40494..f4e99c6 100644 --- a/src/brapi/_base_client.py +++ b/src/brapi/_base_client.py @@ -1774,7 +1774,7 @@ async def patch( options: RequestOptions = {}, ) -> ResponseT: opts = FinalRequestOptions.construct( - method="patch", url=path, json_data=body, files=to_httpx_files(files), **options + method="patch", url=path, json_data=body, files=await async_to_httpx_files(files), **options ) return await self.request(cast_to, opts) From 76c6f31884a3fc3588c955002aba49679fd42e9b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 06:00:30 +0000 Subject: [PATCH 4/5] chore(internal): add `--fix` argument to lint script --- scripts/lint | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/lint b/scripts/lint index e8935a5..5e07b8d 100755 --- a/scripts/lint +++ b/scripts/lint @@ -4,8 +4,13 @@ set -e cd "$(dirname "$0")/.." -echo "==> Running lints" -rye run lint +if [ "$1" = "--fix" ]; then + echo "==> Running lints with --fix" + rye run fix:ruff +else + echo "==> Running lints" + rye run lint +fi echo "==> Making sure it imports" rye run python -c 'import brapi' From b7d451aceb58189007e3752107c1be246aec0126 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 06:00:46 +0000 Subject: [PATCH 5/5] release: 1.0.5 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 15 +++++++++++++++ pyproject.toml | 2 +- src/brapi/_version.py | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 80d368a..1214610 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.0.4" + ".": "1.0.5" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d5ad74c..32b8f3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 1.0.5 (2025-12-19) + +Full Changelog: [v1.0.4...v1.0.5](https://github.com/brapi-dev/brapi-python/compare/v1.0.4...v1.0.5) + +### Bug Fixes + +* use async_to_httpx_files in patch method ([a061229](https://github.com/brapi-dev/brapi-python/commit/a0612291f12c3dbc71faab50d3beb93848801db3)) + + +### Chores + +* **internal:** add `--fix` argument to lint script ([76c6f31](https://github.com/brapi-dev/brapi-python/commit/76c6f31884a3fc3588c955002aba49679fd42e9b)) +* **internal:** add missing files argument to base client ([cababd6](https://github.com/brapi-dev/brapi-python/commit/cababd656bcc34c68419a4d00812965f92e0fa5c)) +* speedup initial import ([7261e02](https://github.com/brapi-dev/brapi-python/commit/7261e025f7cf5448c964892296d7c54999926cdd)) + ## 1.0.4 (2025-12-09) Full Changelog: [v1.0.3...v1.0.4](https://github.com/brapi-dev/brapi-python/compare/v1.0.3...v1.0.4) diff --git a/pyproject.toml b/pyproject.toml index 0ffae3a..cd620ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "brapi" -version = "1.0.4" +version = "1.0.5" description = "The official Python library for the brapi API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/brapi/_version.py b/src/brapi/_version.py index aa6a0a5..7a778d3 100644 --- a/src/brapi/_version.py +++ b/src/brapi/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "brapi" -__version__ = "1.0.4" # x-release-please-version +__version__ = "1.0.5" # x-release-please-version