Skip to content

Commit 710a64b

Browse files
committed
chore: rebuild project due to codegen change
1 parent afa5045 commit 710a64b

18 files changed

+64
-3549
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

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

@@ -318,7 +318,7 @@ print(gitpod.__version__)
318318

319319
## Requirements
320320

321-
Python 3.7 or higher.
321+
Python 3.8 or higher.
322322

323323
## Contributing
324324

Diff for: pyproject.toml

+2-3
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",
@@ -139,7 +138,7 @@ filterwarnings = [
139138
# there are a couple of flags that are still disabled by
140139
# default in strict mode as they are experimental and niche.
141140
typeCheckingMode = "strict"
142-
pythonVersion = "3.7"
141+
pythonVersion = "3.8"
143142

144143
exclude = [
145144
"_dev",

Diff for: requirements-dev.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ markdown-it-py==3.0.0
4848
# via rich
4949
mdurl==0.1.2
5050
# via markdown-it-py
51-
mypy==1.11.2
51+
mypy==1.13.0
5252
mypy-extensions==1.0.0
5353
# via mypy
5454
nodeenv==1.8.0

Diff for: src/gitpod/_compat.py

+4-2
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,

Diff for: src/gitpod/_models.py

+6-3
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,

Diff for: src/gitpod/_utils/__init__.py

+1
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,

Diff for: src/gitpod/_utils/_transform.py

+7-2
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:

Diff for: src/gitpod/_utils/_utils.py

+17
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

Diff for: src/gitpod/resources/environment_automation.py

-209
This file was deleted.

0 commit comments

Comments
 (0)