Skip to content

Commit 265f51d

Browse files
authored
Merge pull request #9 from brapi-dev/release-please--branches--main--changes--next
release: 1.2.0
2 parents 7ce53f2 + b0e962c commit 265f51d

11 files changed

Lines changed: 192 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ${{ github.repository == 'stainless-sdks/brapi-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
2020
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
2121
steps:
22-
- uses: actions/checkout@v4
22+
- uses: actions/checkout@v6
2323

2424
- name: Install Rye
2525
run: |
@@ -44,7 +44,7 @@ jobs:
4444
id-token: write
4545
runs-on: ${{ github.repository == 'stainless-sdks/brapi-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
4646
steps:
47-
- uses: actions/checkout@v4
47+
- uses: actions/checkout@v6
4848

4949
- name: Install Rye
5050
run: |
@@ -63,7 +63,7 @@ jobs:
6363
- name: Get GitHub OIDC Token
6464
if: github.repository == 'stainless-sdks/brapi-python'
6565
id: github-oidc
66-
uses: actions/github-script@v6
66+
uses: actions/github-script@v8
6767
with:
6868
script: core.setOutput('github_token', await core.getIDToken());
6969

@@ -81,7 +81,7 @@ jobs:
8181
runs-on: ${{ github.repository == 'stainless-sdks/brapi-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
8282
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
8383
steps:
84-
- uses: actions/checkout@v4
84+
- uses: actions/checkout@v6
8585

8686
- name: Install Rye
8787
run: |

.github/workflows/publish-pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818

1919
- name: Install Rye
2020
run: |

.github/workflows/release-doctor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
if: github.repository == 'brapi-dev/brapi-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
1313

1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v6
1616

1717
- name: Check release environment
1818
run: |

.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.1.0"
2+
".": "1.2.0"
33
}

CHANGELOG.md

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

3+
## 1.2.0 (2026-01-30)
4+
5+
Full Changelog: [v1.1.0...v1.2.0](https://github.com/brapi-dev/brapi-python/compare/v1.1.0...v1.2.0)
6+
7+
### Features
8+
9+
* **client:** add custom JSON encoder for extended type support ([05834cc](https://github.com/brapi-dev/brapi-python/commit/05834ccc9e905ba5a730eacf03080b93d6acede9))
10+
11+
12+
### Chores
13+
14+
* **ci:** upgrade `actions/github-script` ([c133c8f](https://github.com/brapi-dev/brapi-python/commit/c133c8fa5a7baffae64a019c1fe7825033320509))
15+
* **internal:** update `actions/checkout` version ([3cafae4](https://github.com/brapi-dev/brapi-python/commit/3cafae4bb3e4f151d053cb677159303489836eb9))
16+
317
## 1.1.0 (2026-01-14)
418

519
Full Changelog: [v1.0.5...v1.1.0](https://github.com/brapi-dev/brapi-python/compare/v1.0.5...v1.1.0)

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.1.0"
3+
version = "1.2.0"
44
description = "The official Python library for the brapi API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"

src/brapi/_base_client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
APIConnectionError,
8787
APIResponseValidationError,
8888
)
89+
from ._utils._json import openapi_dumps
8990

9091
log: logging.Logger = logging.getLogger(__name__)
9192

@@ -554,8 +555,10 @@ def _build_request(
554555
kwargs["content"] = options.content
555556
elif isinstance(json_data, bytes):
556557
kwargs["content"] = json_data
557-
else:
558-
kwargs["json"] = json_data if is_given(json_data) else None
558+
elif not files:
559+
# Don't set content when JSON is sent as multipart/form-data,
560+
# since httpx's content param overrides other body arguments
561+
kwargs["content"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None
559562
kwargs["files"] = files
560563
else:
561564
headers.pop("Content-Type", None)

src/brapi/_compat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def model_dump(
139139
exclude_defaults: bool = False,
140140
warnings: bool = True,
141141
mode: Literal["json", "python"] = "python",
142+
by_alias: bool | None = None,
142143
) -> dict[str, Any]:
143144
if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
144145
return model.model_dump(
@@ -148,13 +149,12 @@ def model_dump(
148149
exclude_defaults=exclude_defaults,
149150
# warnings are not supported in Pydantic v1
150151
warnings=True if PYDANTIC_V1 else warnings,
152+
by_alias=by_alias,
151153
)
152154
return cast(
153155
"dict[str, Any]",
154156
model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
155-
exclude=exclude,
156-
exclude_unset=exclude_unset,
157-
exclude_defaults=exclude_defaults,
157+
exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, by_alias=bool(by_alias)
158158
),
159159
)
160160

src/brapi/_utils/_json.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import json
2+
from typing import Any
3+
from datetime import datetime
4+
from typing_extensions import override
5+
6+
import pydantic
7+
8+
from .._compat import model_dump
9+
10+
11+
def openapi_dumps(obj: Any) -> bytes:
12+
"""
13+
Serialize an object to UTF-8 encoded JSON bytes.
14+
15+
Extends the standard json.dumps with support for additional types
16+
commonly used in the SDK, such as `datetime`, `pydantic.BaseModel`, etc.
17+
"""
18+
return json.dumps(
19+
obj,
20+
cls=_CustomEncoder,
21+
# Uses the same defaults as httpx's JSON serialization
22+
ensure_ascii=False,
23+
separators=(",", ":"),
24+
allow_nan=False,
25+
).encode()
26+
27+
28+
class _CustomEncoder(json.JSONEncoder):
29+
@override
30+
def default(self, o: Any) -> Any:
31+
if isinstance(o, datetime):
32+
return o.isoformat()
33+
if isinstance(o, pydantic.BaseModel):
34+
return model_dump(o, exclude_unset=True, mode="json", by_alias=True)
35+
return super().default(o)

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.1.0" # x-release-please-version
4+
__version__ = "1.2.0" # x-release-please-version

0 commit comments

Comments
 (0)