Skip to content

Commit 6c43b97

Browse files
committed
feat: replace python-dateutil with stdlib datetime.fromisoformat
Drop the python-dateutil dependency from both the generator and all generated client code. Date/datetime parsing now uses the stdlib: - datetime fields: datetime.datetime.fromisoformat(v.replace("Z", "+00:00")) - date fields: datetime.date.fromisoformat(v) The .replace("Z", "+00:00") call is needed because Python 3.10's fromisoformat() does not accept the Z timezone suffix (added in 3.11). It is a no-op on strings that do not contain Z. Default values in OpenAPI specs are normalized at generation time (Z replaced with +00:00), so the generated default expressions are clean datetime.datetime.fromisoformat("...") calls without the replace. This removes one runtime dependency from every generated client package, reducing install size and eliminating a dependency that is in maintenance-only mode upstream.
1 parent 5fcaf72 commit 6c43b97

89 files changed

Lines changed: 1117 additions & 1280 deletions

File tree

Some content is hidden

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

end_to_end_tests/docstrings-on-attributes-golden-record/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ include = ["my_test_api_client/py.typed"]
1313
python = "^3.10"
1414
httpx = ">=0.23.0,<0.29.0"
1515
attrs = ">=22.2.0"
16-
python-dateutil = "^2.8.0"
1716

1817
[build-system]
1918
requires = ["poetry-core>=2.0.0,<3.0.0"]

end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def _get_kwargs(
1212
*,
1313
common: str | Unset = UNSET,
1414
) -> dict[str, Any]:
15-
1615
params: dict[str, Any] = {}
1716

1817
params["common"] = common

end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_allof.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212
def _get_kwargs() -> dict[str, Any]:
13-
1413
_kwargs: dict[str, Any] = {
1514
"method": "get",
1615
"url": "/models/allof",

end_to_end_tests/golden-record/my_test_api_client/api/default/get_models_oneof_with_required_const.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616

1717
def _get_kwargs() -> dict[str, Any]:
18-
1918
_kwargs: dict[str, Any] = {
2019
"method": "get",
2120
"url": "/models/oneof-with-required-const",

end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def _get_kwargs(
1212
*,
1313
common: str | Unset = UNSET,
1414
) -> dict[str, Any]:
15-
1615
params: dict[str, Any] = {}
1716

1817
params["common"] = common

end_to_end_tests/golden-record/my_test_api_client/api/default/reserved_parameters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def _get_kwargs(
1313
client_query: str,
1414
url_query: str,
1515
) -> dict[str, Any]:
16-
1716
params: dict[str, Any] = {}
1817

1918
params["client"] = client_query

end_to_end_tests/golden-record/my_test_api_client/api/defaults/defaults_tests_defaults_post.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Any
44

55
import httpx
6-
from dateutil.parser import isoparse
76

87
from ... import errors
98
from ...client import AuthenticatedClient, Client
@@ -17,7 +16,7 @@ def _get_kwargs(
1716
*,
1817
string_prop: str = "the default string",
1918
string_with_num: str = "1",
20-
date_prop: datetime.date = isoparse("1010-10-10").date(),
19+
date_prop: datetime.date = datetime.date.fromisoformat("1010-10-10"),
2120
float_prop: float = 3.14,
2221
float_with_int: float = 3.0,
2322
int_prop: int = 7,
@@ -29,7 +28,6 @@ def _get_kwargs(
2928
model_prop: ModelWithUnionProperty,
3029
required_model_prop: ModelWithUnionProperty,
3130
) -> dict[str, Any]:
32-
3331
params: dict[str, Any] = {}
3432

3533
params["string_prop"] = string_prop
@@ -121,7 +119,7 @@ def sync_detailed(
121119
client: AuthenticatedClient | Client,
122120
string_prop: str = "the default string",
123121
string_with_num: str = "1",
124-
date_prop: datetime.date = isoparse("1010-10-10").date(),
122+
date_prop: datetime.date = datetime.date.fromisoformat("1010-10-10"),
125123
float_prop: float = 3.14,
126124
float_with_int: float = 3.0,
127125
int_prop: int = 7,
@@ -138,7 +136,7 @@ def sync_detailed(
138136
Args:
139137
string_prop (str): Default: 'the default string'.
140138
string_with_num (str): Default: '1'.
141-
date_prop (datetime.date): Default: isoparse('1010-10-10').date().
139+
date_prop (datetime.date): Default: datetime.date.fromisoformat('1010-10-10').
142140
float_prop (float): Default: 3.14.
143141
float_with_int (float): Default: 3.0.
144142
int_prop (int): Default: 7.
@@ -186,7 +184,7 @@ def sync(
186184
client: AuthenticatedClient | Client,
187185
string_prop: str = "the default string",
188186
string_with_num: str = "1",
189-
date_prop: datetime.date = isoparse("1010-10-10").date(),
187+
date_prop: datetime.date = datetime.date.fromisoformat("1010-10-10"),
190188
float_prop: float = 3.14,
191189
float_with_int: float = 3.0,
192190
int_prop: int = 7,
@@ -203,7 +201,7 @@ def sync(
203201
Args:
204202
string_prop (str): Default: 'the default string'.
205203
string_with_num (str): Default: '1'.
206-
date_prop (datetime.date): Default: isoparse('1010-10-10').date().
204+
date_prop (datetime.date): Default: datetime.date.fromisoformat('1010-10-10').
207205
float_prop (float): Default: 3.14.
208206
float_with_int (float): Default: 3.0.
209207
int_prop (int): Default: 7.
@@ -246,7 +244,7 @@ async def asyncio_detailed(
246244
client: AuthenticatedClient | Client,
247245
string_prop: str = "the default string",
248246
string_with_num: str = "1",
249-
date_prop: datetime.date = isoparse("1010-10-10").date(),
247+
date_prop: datetime.date = datetime.date.fromisoformat("1010-10-10"),
250248
float_prop: float = 3.14,
251249
float_with_int: float = 3.0,
252250
int_prop: int = 7,
@@ -263,7 +261,7 @@ async def asyncio_detailed(
263261
Args:
264262
string_prop (str): Default: 'the default string'.
265263
string_with_num (str): Default: '1'.
266-
date_prop (datetime.date): Default: isoparse('1010-10-10').date().
264+
date_prop (datetime.date): Default: datetime.date.fromisoformat('1010-10-10').
267265
float_prop (float): Default: 3.14.
268266
float_with_int (float): Default: 3.0.
269267
int_prop (int): Default: 7.
@@ -309,7 +307,7 @@ async def asyncio(
309307
client: AuthenticatedClient | Client,
310308
string_prop: str = "the default string",
311309
string_with_num: str = "1",
312-
date_prop: datetime.date = isoparse("1010-10-10").date(),
310+
date_prop: datetime.date = datetime.date.fromisoformat("1010-10-10"),
313311
float_prop: float = 3.14,
314312
float_with_int: float = 3.0,
315313
int_prop: int = 7,
@@ -326,7 +324,7 @@ async def asyncio(
326324
Args:
327325
string_prop (str): Default: 'the default string'.
328326
string_with_num (str): Default: '1'.
329-
date_prop (datetime.date): Default: isoparse('1010-10-10').date().
327+
date_prop (datetime.date): Default: datetime.date.fromisoformat('1010-10-10').
330328
float_prop (float): Default: 3.14.
331329
float_with_int (float): Default: 3.0.
332330
int_prop (int): Default: 7.

end_to_end_tests/golden-record/my_test_api_client/api/enums/bool_enum_tests_bool_enum_post.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def _get_kwargs(
1212
*,
1313
bool_enum: bool,
1414
) -> dict[str, Any]:
15-
1615
params: dict[str, Any] = {}
1716

1817
params["bool_enum"] = bool_enum

end_to_end_tests/golden-record/my_test_api_client/api/enums/int_enum_tests_int_enum_post.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ def _get_kwargs(
1313
*,
1414
int_enum: AnIntEnum,
1515
) -> dict[str, Any]:
16-
1716
params: dict[str, Any] = {}
1817

1918
json_int_enum = int_enum.value

end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ def _get_kwargs(
1616
null_not_required: datetime.datetime | None | Unset = UNSET,
1717
not_null_not_required: datetime.datetime | Unset = UNSET,
1818
) -> dict[str, Any]:
19-
2019
params: dict[str, Any] = {}
2120

2221
json_not_null_required = not_null_required.isoformat()

0 commit comments

Comments
 (0)