Skip to content

Commit 04f25d9

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
chore: rebuild project due to codegen change (#13)
1 parent b575f9a commit 04f25d9

File tree

235 files changed

+113
-29241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+113
-29241
lines changed

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/omnistack.svg)](https://pypi.org/project/omnistack/)
44

5-
The Omnistack Python library provides convenient access to the Omnistack REST API from any Python 3.7+
5+
The Omnistack Python library provides convenient access to the Omnistack 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

@@ -335,7 +335,7 @@ print(omnistack.__version__)
335335

336336
## Requirements
337337

338-
Python 3.7 or higher.
338+
Python 3.8 or higher.
339339

340340
## Contributing
341341

pyproject.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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",
@@ -66,7 +65,6 @@ format = { chain = [
6665
# run formatting again to fix any inconsistencies when imports are stripped
6766
"format:ruff",
6867
]}
69-
"format:black" = "black ."
7068
"format:docs" = "python scripts/utils/ruffen-docs.py README.md api.md"
7169
"format:ruff" = "ruff format"
7270

@@ -126,10 +124,6 @@ path = "README.md"
126124
pattern = '\[(.+?)\]\(((?!https?://)\S+?)\)'
127125
replacement = '[\1](https://github.com/OmniStack-sh/omnistack-python/tree/main/\g<2>)'
128126

129-
[tool.black]
130-
line-length = 120
131-
target-version = ["py37"]
132-
133127
[tool.pytest.ini_options]
134128
testpaths = ["tests"]
135129
addopts = "--tb=short"
@@ -144,7 +138,7 @@ filterwarnings = [
144138
# there are a couple of flags that are still disabled by
145139
# default in strict mode as they are experimental and niche.
146140
typeCheckingMode = "strict"
147-
pythonVersion = "3.7"
141+
pythonVersion = "3.8"
148142

149143
exclude = [
150144
"_dev",

requirements-dev.lock

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ anyio==4.4.0
1616
# via omnistack
1717
argcomplete==3.1.2
1818
# via nox
19-
attrs==23.1.0
20-
# via pytest
2119
certifi==2023.7.22
2220
# via httpcore
2321
# via httpx
@@ -28,8 +26,9 @@ distlib==0.3.7
2826
# via virtualenv
2927
distro==1.8.0
3028
# via omnistack
31-
exceptiongroup==1.1.3
29+
exceptiongroup==1.2.2
3230
# via anyio
31+
# via pytest
3332
filelock==3.12.4
3433
# via virtualenv
3534
h11==0.14.0
@@ -49,7 +48,7 @@ markdown-it-py==3.0.0
4948
# via rich
5049
mdurl==0.1.2
5150
# via markdown-it-py
52-
mypy==1.11.2
51+
mypy==1.13.0
5352
mypy-extensions==1.0.0
5453
# via mypy
5554
nodeenv==1.8.0
@@ -60,20 +59,18 @@ packaging==23.2
6059
# via pytest
6160
platformdirs==3.11.0
6261
# via virtualenv
63-
pluggy==1.3.0
64-
# via pytest
65-
py==1.11.0
62+
pluggy==1.5.0
6663
# via pytest
67-
pydantic==2.7.1
64+
pydantic==2.9.2
6865
# via omnistack
69-
pydantic-core==2.18.2
66+
pydantic-core==2.23.4
7067
# via pydantic
7168
pygments==2.18.0
7269
# via rich
7370
pyright==1.1.380
74-
pytest==7.1.1
71+
pytest==8.3.3
7572
# via pytest-asyncio
76-
pytest-asyncio==0.21.1
73+
pytest-asyncio==0.24.0
7774
python-dateutil==2.8.2
7875
# via time-machine
7976
pytz==2023.3.post1
@@ -90,10 +87,10 @@ sniffio==1.3.0
9087
# via httpx
9188
# via omnistack
9289
time-machine==2.9.0
93-
tomli==2.0.1
90+
tomli==2.0.2
9491
# via mypy
9592
# via pytest
96-
typing-extensions==4.8.0
93+
typing-extensions==4.12.2
9794
# via anyio
9895
# via mypy
9996
# via omnistack

requirements.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ certifi==2023.7.22
1919
# via httpx
2020
distro==1.8.0
2121
# via omnistack
22-
exceptiongroup==1.1.3
22+
exceptiongroup==1.2.2
2323
# via anyio
2424
h11==0.14.0
2525
# via httpcore
@@ -30,15 +30,15 @@ httpx==0.25.2
3030
idna==3.4
3131
# via anyio
3232
# via httpx
33-
pydantic==2.7.1
33+
pydantic==2.9.2
3434
# via omnistack
35-
pydantic-core==2.18.2
35+
pydantic-core==2.23.4
3636
# via pydantic
3737
sniffio==1.3.0
3838
# via anyio
3939
# via httpx
4040
# via omnistack
41-
typing-extensions==4.8.0
41+
typing-extensions==4.12.2
4242
# via anyio
4343
# via omnistack
4444
# via pydantic

src/omnistack/_base_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ async def _request(
15751575
except Exception as err:
15761576
log.debug("Encountered Exception", exc_info=True)
15771577

1578-
if retries_taken > 0:
1578+
if remaining_retries > 0:
15791579
return await self._retry_request(
15801580
input_options,
15811581
cast_to,

src/omnistack/_compat.py

Lines changed: 5 additions & 3 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
@@ -133,13 +133,15 @@ def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str:
133133
def model_dump(
134134
model: pydantic.BaseModel,
135135
*,
136-
exclude: IncEx = None,
136+
exclude: IncEx | None = None,
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/omnistack/_models.py

Lines changed: 11 additions & 8 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,
@@ -176,7 +177,7 @@ def __str__(self) -> str:
176177
# Based on https://github.com/samuelcolvin/pydantic/issues/1168#issuecomment-817742836.
177178
@classmethod
178179
@override
179-
def construct(
180+
def construct( # pyright: ignore[reportIncompatibleMethodOverride]
180181
cls: Type[ModelT],
181182
_fields_set: set[str] | None = None,
182183
**values: object,
@@ -248,8 +249,8 @@ def model_dump(
248249
self,
249250
*,
250251
mode: Literal["json", "python"] | str = "python",
251-
include: IncEx = None,
252-
exclude: IncEx = None,
252+
include: IncEx | None = None,
253+
exclude: IncEx | None = None,
253254
by_alias: bool = False,
254255
exclude_unset: bool = False,
255256
exclude_defaults: bool = False,
@@ -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,13 +299,15 @@ 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,
304307
*,
305308
indent: int | None = None,
306-
include: IncEx = None,
307-
exclude: IncEx = None,
309+
include: IncEx | None = None,
310+
exclude: IncEx | None = None,
308311
by_alias: bool = False,
309312
exclude_unset: bool = False,
310313
exclude_defaults: bool = False,

src/omnistack/_types.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Optional,
1717
Sequence,
1818
)
19-
from typing_extensions import Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
19+
from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable
2020

2121
import httpx
2222
import pydantic
@@ -193,7 +193,9 @@ def get(self, __key: str) -> str | None: ...
193193

194194
# Note: copied from Pydantic
195195
# https://github.com/pydantic/pydantic/blob/32ea570bf96e84234d2992e1ddf40ab8a565925a/pydantic/main.py#L49
196-
IncEx: TypeAlias = "set[int] | set[str] | dict[int, Any] | dict[str, Any] | None"
196+
IncEx: TypeAlias = Union[
197+
Set[int], Set[str], Mapping[int, Union["IncEx", Literal[True]]], Mapping[str, Union["IncEx", Literal[True]]]
198+
]
197199

198200
PostParser = Callable[[Any], Any]
199201

src/omnistack/_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/omnistack/_utils/_transform.py

Lines changed: 7 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:
@@ -324,7 +329,7 @@ async def _async_transform_recursive(
324329
return data
325330

326331
if isinstance(data, pydantic.BaseModel):
327-
return model_dump(data, exclude_unset=True)
332+
return model_dump(data, exclude_unset=True, mode="json")
328333

329334
annotated_type = _get_annotated_type(annotation)
330335
if annotated_type is None:

0 commit comments

Comments
 (0)