Skip to content

fix(python): add missing Pendulum Interval wrapper support - #379

Merged
yezz123 merged 2 commits into
pydantic:mainfrom
RedZapdos123:fix/pendulum-interval-wrapper-364
Apr 5, 2026
Merged

yezz123 merged 2 commits into
pydantic:mainfrom
RedZapdos123:fix/pendulum-interval-wrapper-364

Conversation

@RedZapdos123

@RedZapdos123 RedZapdos123 commented Apr 5, 2026 •

Copy link
Copy Markdown
Contributor

Description:

I noticed this happened because pendulum_dt already wraps DateTime, Date, Time, and Duration, but there was no wrapper for Interval. That made Interval unavailable as a first class validated type in this module. This PR adds the missing wrapper, validates existing pendulum.Interval values, parses ISO-8601 interval strings, and returns the project specific wrapper type. It also adds focused tests for valid and invalid interval inputs.

Closes #364

AI Assistance Disclosure:

  • Tool(s) used: GitHub Copilot (GPT-5.3-Codex).
  • Scope: Helped with code edits, tests, and PR drafting.
  • Verification: Ran uv run pytest tests/test_pendulum_dt.py -q in WSL (209 passed) and ran make lint (passed).

Checklist:

  • I have reviewed all changes in this PR, manually.
  • I have added a relevant test case for this fix.
  • I have run the linting and formatting scripts (make lint).

Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
Signed-off-by: Mridankan Mandal <xerontitan90@gmail.com>
@yezz123
yezz123 merged commit e923517 into pydantic:main Apr 5, 2026
10 checks passed
zzstoatzz added a commit to PrefectHQ/prefect that referenced this pull request Apr 8, 2026
pydantic-extra-types 2.11.2 (pydantic/pydantic-extra-types#379) added a
pendulum `Interval` wrapper that does `class Interval(_Interval[Any])`. This
requires `pendulum.Interval` to be a `Generic`, which it only became in
pendulum 3.1. On environments pinned to pendulum 3.0.0, any `import prefect`
fails at module load with:

    TypeError: type 'Interval' is not subscriptable

because `prefect/types/_datetime.py` imports from `pydantic_extra_types.pendulum_dt`
on Python < 3.13.

Bump the floor to `pendulum>=3.1.0` in both `pyproject.toml` and
`client/pyproject.toml` so resolvers steer users onto a pendulum release that
is compatible with the current `pydantic-extra-types`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[pendulum] Missing wrapper for Interval type

2 participants