Skip to content

Commit 70562f8

Browse files
authored
Merge pull request #7 from brapi-dev/release-please--branches--main--changes--next
release: 1.0.5
2 parents c229f6e + b7d451a commit 70562f8

7 files changed

Lines changed: 175 additions & 44 deletions

File tree

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "1.0.4"
2+
".": "1.0.5"
33
}

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## 1.0.5 (2025-12-19)
4+
5+
Full Changelog: [v1.0.4...v1.0.5](https://github.com/brapi-dev/brapi-python/compare/v1.0.4...v1.0.5)
6+
7+
### Bug Fixes
8+
9+
* use async_to_httpx_files in patch method ([a061229](https://github.com/brapi-dev/brapi-python/commit/a0612291f12c3dbc71faab50d3beb93848801db3))
10+
11+
12+
### Chores
13+
14+
* **internal:** add `--fix` argument to lint script ([76c6f31](https://github.com/brapi-dev/brapi-python/commit/76c6f31884a3fc3588c955002aba49679fd42e9b))
15+
* **internal:** add missing files argument to base client ([cababd6](https://github.com/brapi-dev/brapi-python/commit/cababd656bcc34c68419a4d00812965f92e0fa5c))
16+
* speedup initial import ([7261e02](https://github.com/brapi-dev/brapi-python/commit/7261e025f7cf5448c964892296d7c54999926cdd))
17+
318
## 1.0.4 (2025-12-09)
419

520
Full Changelog: [v1.0.3...v1.0.4](https://github.com/brapi-dev/brapi-python/compare/v1.0.3...v1.0.4)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "brapi"
3-
version = "1.0.4"
3+
version = "1.0.5"
44
description = "The official Python library for the brapi API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

scripts/lint

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
echo "==> Running lints"
8-
rye run lint
7+
if [ "$1" = "--fix" ]; then
8+
echo "==> Running lints with --fix"
9+
rye run fix:ruff
10+
else
11+
echo "==> Running lints"
12+
rye run lint
13+
fi
914

1015
echo "==> Making sure it imports"
1116
rye run python -c 'import brapi'

src/brapi/_base_client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,9 +1247,12 @@ def patch(
12471247
*,
12481248
cast_to: Type[ResponseT],
12491249
body: Body | None = None,
1250+
files: RequestFiles | None = None,
12501251
options: RequestOptions = {},
12511252
) -> ResponseT:
1252-
opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options)
1253+
opts = FinalRequestOptions.construct(
1254+
method="patch", url=path, json_data=body, files=to_httpx_files(files), **options
1255+
)
12531256
return self.request(cast_to, opts)
12541257

12551258
def put(
@@ -1767,9 +1770,12 @@ async def patch(
17671770
*,
17681771
cast_to: Type[ResponseT],
17691772
body: Body | None = None,
1773+
files: RequestFiles | None = None,
17701774
options: RequestOptions = {},
17711775
) -> ResponseT:
1772-
opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options)
1776+
opts = FinalRequestOptions.construct(
1777+
method="patch", url=path, json_data=body, files=await async_to_httpx_files(files), **options
1778+
)
17731779
return await self.request(cast_to, opts)
17741780

17751781
async def put(

src/brapi/_client.py

Lines changed: 142 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
import os
6-
from typing import Any, Dict, Mapping, cast
6+
from typing import TYPE_CHECKING, Any, Dict, Mapping, cast
77
from typing_extensions import Self, Literal, override
88

99
import httpx
@@ -20,16 +20,21 @@
2020
not_given,
2121
)
2222
from ._utils import is_given, get_async_library
23+
from ._compat import cached_property
2324
from ._version import __version__
24-
from .resources import quote, available
2525
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
2626
from ._exceptions import BrapiError, APIStatusError
2727
from ._base_client import (
2828
DEFAULT_MAX_RETRIES,
2929
SyncAPIClient,
3030
AsyncAPIClient,
3131
)
32-
from .resources.v2 import v2
32+
33+
if TYPE_CHECKING:
34+
from .resources import v2, quote, available
35+
from .resources.quote import QuoteResource, AsyncQuoteResource
36+
from .resources.v2.v2 import V2Resource, AsyncV2Resource
37+
from .resources.available import AvailableResource, AsyncAvailableResource
3338

3439
__all__ = [
3540
"ENVIRONMENTS",
@@ -50,12 +55,6 @@
5055

5156

5257
class Brapi(SyncAPIClient):
53-
quote: quote.QuoteResource
54-
available: available.AvailableResource
55-
v2: v2.V2Resource
56-
with_raw_response: BrapiWithRawResponse
57-
with_streaming_response: BrapiWithStreamedResponse
58-
5958
# client options
6059
api_key: str
6160

@@ -134,11 +133,31 @@ def __init__(
134133
_strict_response_validation=_strict_response_validation,
135134
)
136135

137-
self.quote = quote.QuoteResource(self)
138-
self.available = available.AvailableResource(self)
139-
self.v2 = v2.V2Resource(self)
140-
self.with_raw_response = BrapiWithRawResponse(self)
141-
self.with_streaming_response = BrapiWithStreamedResponse(self)
136+
@cached_property
137+
def quote(self) -> QuoteResource:
138+
from .resources.quote import QuoteResource
139+
140+
return QuoteResource(self)
141+
142+
@cached_property
143+
def available(self) -> AvailableResource:
144+
from .resources.available import AvailableResource
145+
146+
return AvailableResource(self)
147+
148+
@cached_property
149+
def v2(self) -> V2Resource:
150+
from .resources.v2 import V2Resource
151+
152+
return V2Resource(self)
153+
154+
@cached_property
155+
def with_raw_response(self) -> BrapiWithRawResponse:
156+
return BrapiWithRawResponse(self)
157+
158+
@cached_property
159+
def with_streaming_response(self) -> BrapiWithStreamedResponse:
160+
return BrapiWithStreamedResponse(self)
142161

143162
@property
144163
@override
@@ -248,12 +267,6 @@ def _make_status_error(
248267

249268

250269
class AsyncBrapi(AsyncAPIClient):
251-
quote: quote.AsyncQuoteResource
252-
available: available.AsyncAvailableResource
253-
v2: v2.AsyncV2Resource
254-
with_raw_response: AsyncBrapiWithRawResponse
255-
with_streaming_response: AsyncBrapiWithStreamedResponse
256-
257270
# client options
258271
api_key: str
259272

@@ -332,11 +345,31 @@ def __init__(
332345
_strict_response_validation=_strict_response_validation,
333346
)
334347

335-
self.quote = quote.AsyncQuoteResource(self)
336-
self.available = available.AsyncAvailableResource(self)
337-
self.v2 = v2.AsyncV2Resource(self)
338-
self.with_raw_response = AsyncBrapiWithRawResponse(self)
339-
self.with_streaming_response = AsyncBrapiWithStreamedResponse(self)
348+
@cached_property
349+
def quote(self) -> AsyncQuoteResource:
350+
from .resources.quote import AsyncQuoteResource
351+
352+
return AsyncQuoteResource(self)
353+
354+
@cached_property
355+
def available(self) -> AsyncAvailableResource:
356+
from .resources.available import AsyncAvailableResource
357+
358+
return AsyncAvailableResource(self)
359+
360+
@cached_property
361+
def v2(self) -> AsyncV2Resource:
362+
from .resources.v2 import AsyncV2Resource
363+
364+
return AsyncV2Resource(self)
365+
366+
@cached_property
367+
def with_raw_response(self) -> AsyncBrapiWithRawResponse:
368+
return AsyncBrapiWithRawResponse(self)
369+
370+
@cached_property
371+
def with_streaming_response(self) -> AsyncBrapiWithStreamedResponse:
372+
return AsyncBrapiWithStreamedResponse(self)
340373

341374
@property
342375
@override
@@ -446,31 +479,103 @@ def _make_status_error(
446479

447480

448481
class BrapiWithRawResponse:
482+
_client: Brapi
483+
449484
def __init__(self, client: Brapi) -> None:
450-
self.quote = quote.QuoteResourceWithRawResponse(client.quote)
451-
self.available = available.AvailableResourceWithRawResponse(client.available)
452-
self.v2 = v2.V2ResourceWithRawResponse(client.v2)
485+
self._client = client
486+
487+
@cached_property
488+
def quote(self) -> quote.QuoteResourceWithRawResponse:
489+
from .resources.quote import QuoteResourceWithRawResponse
490+
491+
return QuoteResourceWithRawResponse(self._client.quote)
492+
493+
@cached_property
494+
def available(self) -> available.AvailableResourceWithRawResponse:
495+
from .resources.available import AvailableResourceWithRawResponse
496+
497+
return AvailableResourceWithRawResponse(self._client.available)
498+
499+
@cached_property
500+
def v2(self) -> v2.V2ResourceWithRawResponse:
501+
from .resources.v2 import V2ResourceWithRawResponse
502+
503+
return V2ResourceWithRawResponse(self._client.v2)
453504

454505

455506
class AsyncBrapiWithRawResponse:
507+
_client: AsyncBrapi
508+
456509
def __init__(self, client: AsyncBrapi) -> None:
457-
self.quote = quote.AsyncQuoteResourceWithRawResponse(client.quote)
458-
self.available = available.AsyncAvailableResourceWithRawResponse(client.available)
459-
self.v2 = v2.AsyncV2ResourceWithRawResponse(client.v2)
510+
self._client = client
511+
512+
@cached_property
513+
def quote(self) -> quote.AsyncQuoteResourceWithRawResponse:
514+
from .resources.quote import AsyncQuoteResourceWithRawResponse
515+
516+
return AsyncQuoteResourceWithRawResponse(self._client.quote)
517+
518+
@cached_property
519+
def available(self) -> available.AsyncAvailableResourceWithRawResponse:
520+
from .resources.available import AsyncAvailableResourceWithRawResponse
521+
522+
return AsyncAvailableResourceWithRawResponse(self._client.available)
523+
524+
@cached_property
525+
def v2(self) -> v2.AsyncV2ResourceWithRawResponse:
526+
from .resources.v2 import AsyncV2ResourceWithRawResponse
527+
528+
return AsyncV2ResourceWithRawResponse(self._client.v2)
460529

461530

462531
class BrapiWithStreamedResponse:
532+
_client: Brapi
533+
463534
def __init__(self, client: Brapi) -> None:
464-
self.quote = quote.QuoteResourceWithStreamingResponse(client.quote)
465-
self.available = available.AvailableResourceWithStreamingResponse(client.available)
466-
self.v2 = v2.V2ResourceWithStreamingResponse(client.v2)
535+
self._client = client
536+
537+
@cached_property
538+
def quote(self) -> quote.QuoteResourceWithStreamingResponse:
539+
from .resources.quote import QuoteResourceWithStreamingResponse
540+
541+
return QuoteResourceWithStreamingResponse(self._client.quote)
542+
543+
@cached_property
544+
def available(self) -> available.AvailableResourceWithStreamingResponse:
545+
from .resources.available import AvailableResourceWithStreamingResponse
546+
547+
return AvailableResourceWithStreamingResponse(self._client.available)
548+
549+
@cached_property
550+
def v2(self) -> v2.V2ResourceWithStreamingResponse:
551+
from .resources.v2 import V2ResourceWithStreamingResponse
552+
553+
return V2ResourceWithStreamingResponse(self._client.v2)
467554

468555

469556
class AsyncBrapiWithStreamedResponse:
557+
_client: AsyncBrapi
558+
470559
def __init__(self, client: AsyncBrapi) -> None:
471-
self.quote = quote.AsyncQuoteResourceWithStreamingResponse(client.quote)
472-
self.available = available.AsyncAvailableResourceWithStreamingResponse(client.available)
473-
self.v2 = v2.AsyncV2ResourceWithStreamingResponse(client.v2)
560+
self._client = client
561+
562+
@cached_property
563+
def quote(self) -> quote.AsyncQuoteResourceWithStreamingResponse:
564+
from .resources.quote import AsyncQuoteResourceWithStreamingResponse
565+
566+
return AsyncQuoteResourceWithStreamingResponse(self._client.quote)
567+
568+
@cached_property
569+
def available(self) -> available.AsyncAvailableResourceWithStreamingResponse:
570+
from .resources.available import AsyncAvailableResourceWithStreamingResponse
571+
572+
return AsyncAvailableResourceWithStreamingResponse(self._client.available)
573+
574+
@cached_property
575+
def v2(self) -> v2.AsyncV2ResourceWithStreamingResponse:
576+
from .resources.v2 import AsyncV2ResourceWithStreamingResponse
577+
578+
return AsyncV2ResourceWithStreamingResponse(self._client.v2)
474579

475580

476581
Client = Brapi

src/brapi/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "brapi"
4-
__version__ = "1.0.4" # x-release-please-version
4+
__version__ = "1.0.5" # x-release-please-version

0 commit comments

Comments
 (0)