| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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.
Make the .replace("Z", "+00:00") workaround discoverable by both
`rg TODO` and `rg "3.10|py3.10"` so it can be cleanly removed
when the project drops Python 3.10 support.
Brings in 8 commits since the PR opened, notably:
- typer constraint bump to <0.27
- uv_build 0.11 template update
- mypy v2 cast cleanup in generated output
Conflict resolution:
- pdm.lock, integration-tests/pdm.lock: regenerated via 'pdm lock'
against the merged pyproject.toml.
- Golden records: regenerated via 'pdm run regen' to absorb the
mypy-cast cleanup; the dateutil -> fromisoformat change from this
branch is preserved.
Verified locally with ruff check, ruff format --check, mypy, and the
unit-test suite (283 passed, 4 skipped).
The minimal lockfiles were previously regenerated without
'-S direct_minimal_versions', so direct dependencies were locked
to highest-compatible versions instead of lowest. That defeats the
point of the test_min_deps CI job, which exists to verify the
declared lower bounds in pyproject.toml still work.
Re-locked both pdm.minimal.lock files using:
pdm lock -S direct_minimal_versions -L pdm.minimal.lock
Strategy marker confirmed as
["direct_minimal_versions", "inherit_metadata"] in the metadata
of both files. python-dateutil is absent (this branch's main change).
There was a problem hiding this comment.
Thanks!
Sorry, something went wrong.
|
Turns out fractional seconds also aren't really supported in Python 3.10, caught by intermittent failures in the integration tests 😒. I think I'll just drop 3.10 support for this release, there's only a few months left of security support for it anyway. |
Sorry, something went wrong.
> [!IMPORTANT] > Merging this pull request will create this release ## Breaking Changes - Drop support for Python 3.10 - Raise minimum httpx version to 0.23.1 ## Features - replace python-dateutil with stdlib datetime.fromisoformat (openapi-generators#1429) ## Fixes - Remove some generated casts that aren't necessary with mypy v2 (openapi-generators#1436) - Explicitly set boundary for multipart/form-data (openapi-generators#1005) Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Summary
Drop the python-dateutil dependency from both the generator and all generated client packages. Date/datetime parsing now uses Python's built-in datetime.fromisoformat() instead of dateutil.parser.isoparse().
This removes one runtime dependency from every generated client, reducing install size and eliminating a dependency that is unmaintained upstream and being deprecated by Fedora 45 (no releases since March 2024).
Changes
Generator source (openapi_python_client/parser/properties/):
Jinja templates (openapi_python_client/templates/property_templates/):
Dependency removal (all 4 metadata formats):
Tests & golden records: All regenerated. Unit tests pass (283 passed, 4 skipped).
Python 3.10 compatibility
datetime.fromisoformat() gained full ISO 8601 support (including the Z suffix) in Python 3.11. On Python 3.10, the Z suffix raises a ValueError:
The generated datetime parsing code uses .replace("Z", "+00:00") to normalize Z to an explicit UTC offset before calling fromisoformat(), which works on both 3.10 and 3.11+. This is a no-op on strings without Z. Date parsing does not need this since date strings have no timezone component.
Default values in OpenAPI specs are normalized at generation time (Z -> +00:00), so the emitted default expressions are clean datetime.datetime.fromisoformat("...") calls.