Skip to content

Commit db66a27

Browse files
stainless-app[bot]Stainless Bot
andauthored
release: 1.0.1 (#52)
* feat(api): api update (#48) * feat(api): api update (#51) * chore: rebuild project due to codegen change (#53) * chore: rebuild project due to codegen change (#54) * chore: rebuild project due to codegen change (#55) * chore: rebuild project due to codegen change (#57) * chore: rebuild project due to codegen change (#58) * release: 1.0.1 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> Co-authored-by: Stainless Bot <[email protected]>
1 parent d865f5e commit db66a27

File tree

18 files changed

+102
-46
lines changed

18 files changed

+102
-46
lines changed

.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.0"
2+
".": "1.0.1"
33
}

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 18
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-b341dd9d5bb77c4f217b94b186763e730fd798fbb773a5e90bb4e2a8d4a2c822.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-7f88912695bab2b98cb73137e6f36125d02fdfaf8eed4532ee1c82385609a259.yml

CHANGELOG.md

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

3+
## 1.0.1 (2024-11-18)
4+
5+
Full Changelog: [v1.0.0...v1.0.1](https://github.com/browserbase/sdk-python/compare/v1.0.0...v1.0.1)
6+
7+
### Features
8+
9+
* **api:** api update ([#48](https://github.com/browserbase/sdk-python/issues/48)) ([b17a3b8](https://github.com/browserbase/sdk-python/commit/b17a3b8e6984447421a7581ca56c0521cb3b55dd))
10+
* **api:** api update ([#51](https://github.com/browserbase/sdk-python/issues/51)) ([dc2da25](https://github.com/browserbase/sdk-python/commit/dc2da25d2e33d55e5655cbb8000fd4afdd6bbf62))
11+
12+
13+
### Chores
14+
15+
* rebuild project due to codegen change ([#53](https://github.com/browserbase/sdk-python/issues/53)) ([b1684fa](https://github.com/browserbase/sdk-python/commit/b1684fa889aecf2fe7965a37ebd9c73977136ef6))
16+
* rebuild project due to codegen change ([#54](https://github.com/browserbase/sdk-python/issues/54)) ([e6a41da](https://github.com/browserbase/sdk-python/commit/e6a41dab6f0de6894a97067611166b1bc61893a2))
17+
* rebuild project due to codegen change ([#55](https://github.com/browserbase/sdk-python/issues/55)) ([ff17087](https://github.com/browserbase/sdk-python/commit/ff1708757bdeaa4e6b8d1959d1830105bd7f4b92))
18+
* rebuild project due to codegen change ([#57](https://github.com/browserbase/sdk-python/issues/57)) ([dfd0e19](https://github.com/browserbase/sdk-python/commit/dfd0e199c2447d4bd1b6704745d22f959a6b6bb1))
19+
* rebuild project due to codegen change ([#58](https://github.com/browserbase/sdk-python/issues/58)) ([f3be0be](https://github.com/browserbase/sdk-python/commit/f3be0bec13d95c65ab4cc81565b456cb566a62e2))
20+
321
## 1.0.0 (2024-10-29)
422

523
Full Changelog: [v1.0.0-alpha.0...v1.0.0](https://github.com/browserbase/sdk-python/compare/v1.0.0-alpha.0...v1.0.0)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![PyPI version](https://img.shields.io/pypi/v/browserbase.svg)](https://pypi.org/project/browserbase/)
44

5-
The Browserbase Python library provides convenient access to the Browserbase REST API from any Python 3.7+
5+
The Browserbase Python library provides convenient access to the Browserbase REST API from any Python 3.8+
66
application. The library includes type definitions for all request params and response fields,
77
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
88

@@ -340,7 +340,7 @@ print(browserbase.__version__)
340340

341341
## Requirements
342342

343-
Python 3.7 or higher.
343+
Python 3.8 or higher.
344344

345345
## Contributing
346346

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "browserbase"
3-
version = "1.0.0"
3+
version = "1.0.1"
44
description = "The official Python library for the Browserbase API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"
@@ -16,11 +16,10 @@ dependencies = [
1616
"sniffio",
1717
"cached-property; python_version < '3.8'",
1818
]
19-
requires-python = ">= 3.7"
19+
requires-python = ">= 3.8"
2020
classifiers = [
2121
"Typing :: Typed",
2222
"Intended Audience :: Developers",
23-
"Programming Language :: Python :: 3.7",
2423
"Programming Language :: Python :: 3.8",
2524
"Programming Language :: Python :: 3.9",
2625
"Programming Language :: Python :: 3.10",
@@ -148,7 +147,7 @@ filterwarnings = [
148147
# there are a couple of flags that are still disabled by
149148
# default in strict mode as they are experimental and niche.
150149
typeCheckingMode = "strict"
151-
pythonVersion = "3.7"
150+
pythonVersion = "3.8"
152151

153152
exclude = [
154153
"_dev",

src/browserbase/_compat.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import TYPE_CHECKING, Any, Union, Generic, TypeVar, Callable, cast, overload
44
from datetime import date, datetime
5-
from typing_extensions import Self
5+
from typing_extensions import Self, Literal
66

77
import pydantic
88
from pydantic.fields import FieldInfo
@@ -137,9 +137,11 @@ def model_dump(
137137
exclude_unset: bool = False,
138138
exclude_defaults: bool = False,
139139
warnings: bool = True,
140+
mode: Literal["json", "python"] = "python",
140141
) -> dict[str, Any]:
141-
if PYDANTIC_V2:
142+
if PYDANTIC_V2 or hasattr(model, "model_dump"):
142143
return model.model_dump(
144+
mode=mode,
143145
exclude=exclude,
144146
exclude_unset=exclude_unset,
145147
exclude_defaults=exclude_defaults,

src/browserbase/_models.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
PropertyInfo,
3838
is_list,
3939
is_given,
40+
json_safe,
4041
lru_cache,
4142
is_mapping,
4243
parse_date,
@@ -279,8 +280,8 @@ def model_dump(
279280
Returns:
280281
A dictionary representation of the model.
281282
"""
282-
if mode != "python":
283-
raise ValueError("mode is only supported in Pydantic v2")
283+
if mode not in {"json", "python"}:
284+
raise ValueError("mode must be either 'json' or 'python'")
284285
if round_trip != False:
285286
raise ValueError("round_trip is only supported in Pydantic v2")
286287
if warnings != True:
@@ -289,7 +290,7 @@ def model_dump(
289290
raise ValueError("context is only supported in Pydantic v2")
290291
if serialize_as_any != False:
291292
raise ValueError("serialize_as_any is only supported in Pydantic v2")
292-
return super().dict( # pyright: ignore[reportDeprecated]
293+
dumped = super().dict( # pyright: ignore[reportDeprecated]
293294
include=include,
294295
exclude=exclude,
295296
by_alias=by_alias,
@@ -298,6 +299,8 @@ def model_dump(
298299
exclude_none=exclude_none,
299300
)
300301

302+
return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped
303+
301304
@override
302305
def model_dump_json(
303306
self,

src/browserbase/_utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
is_list as is_list,
77
is_given as is_given,
88
is_tuple as is_tuple,
9+
json_safe as json_safe,
910
lru_cache as lru_cache,
1011
is_mapping as is_mapping,
1112
is_tuple_t as is_tuple_t,

src/browserbase/_utils/_transform.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ def _transform_recursive(
173173
# Iterable[T]
174174
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
175175
):
176+
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
177+
# intended as an iterable, so we don't transform it.
178+
if isinstance(data, dict):
179+
return cast(object, data)
180+
176181
inner_type = extract_type_arg(stripped_type, 0)
177182
return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
178183

@@ -186,7 +191,7 @@ def _transform_recursive(
186191
return data
187192

188193
if isinstance(data, pydantic.BaseModel):
189-
return model_dump(data, exclude_unset=True)
194+
return model_dump(data, exclude_unset=True, mode="json")
190195

191196
annotated_type = _get_annotated_type(annotation)
192197
if annotated_type is None:
@@ -311,6 +316,11 @@ async def _async_transform_recursive(
311316
# Iterable[T]
312317
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
313318
):
319+
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
320+
# intended as an iterable, so we don't transform it.
321+
if isinstance(data, dict):
322+
return cast(object, data)
323+
314324
inner_type = extract_type_arg(stripped_type, 0)
315325
return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
316326

@@ -324,7 +334,7 @@ async def _async_transform_recursive(
324334
return data
325335

326336
if isinstance(data, pydantic.BaseModel):
327-
return model_dump(data, exclude_unset=True)
337+
return model_dump(data, exclude_unset=True, mode="json")
328338

329339
annotated_type = _get_annotated_type(annotation)
330340
if annotated_type is None:

src/browserbase/_utils/_utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
overload,
1717
)
1818
from pathlib import Path
19+
from datetime import date, datetime
1920
from typing_extensions import TypeGuard
2021

2122
import sniffio
@@ -395,3 +396,19 @@ def lru_cache(*, maxsize: int | None = 128) -> Callable[[CallableT], CallableT]:
395396
maxsize=maxsize,
396397
)
397398
return cast(Any, wrapper) # type: ignore[no-any-return]
399+
400+
401+
def json_safe(data: object) -> object:
402+
"""Translates a mapping / sequence recursively in the same fashion
403+
as `pydantic` v2's `model_dump(mode="json")`.
404+
"""
405+
if is_mapping(data):
406+
return {json_safe(key): json_safe(value) for key, value in data.items()}
407+
408+
if is_iterable(data) and not isinstance(data, (str, bytes, bytearray)):
409+
return [json_safe(item) for item in data]
410+
411+
if isinstance(data, (datetime, date)):
412+
return data.isoformat()
413+
414+
return data

0 commit comments

Comments
 (0)