Skip to content
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 .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.0.4"
".": "1.0.5"
}
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
9 changes: 7 additions & 2 deletions scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -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'
10 changes: 8 additions & 2 deletions src/brapi/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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=await async_to_httpx_files(files), **options
)
return await self.request(cast_to, opts)

async def put(
Expand Down
179 changes: 142 additions & 37 deletions src/brapi/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,16 +20,21 @@
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 (
DEFAULT_MAX_RETRIES,
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",
Expand All @@ -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

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

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