Support for Pendulum
theunkn0wn1 opened this issue · comments
Initial Checks
- I confirm that I'm using Pydantic V2
Description
Attempting to use datetime sources other than (and better than) stdlib results in errors under pydantic 2.0
This is a regression from 1.x
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'pendulum.datetime.DateTime'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.
Example Code
from pydantic import BaseModel
from pendulum import DateTime
class Example(BaseModel):
last_modified: DateTime
Python, Pydantic & OS Version
python -c "import pydantic.version; print(pydantic.version.version_info())"
pydantic version: 2.4.2
pydantic-core version: 2.10.1
pydantic-core build: profile=release pgo=true
install path: /home/REDACTED/.cache/pypoetry/virtualenvs/REDACTED-XAw2sOhv-py3.10/lib/python3.10/site-packages/pydantic
python version: 3.10.11 (main, Apr 20 2023, 14:14:57) [GCC 9.4.0]
platform: Linux-5.15.0-84-generic-x86_64-with-glibc2.35
related packages: typing_extensions-4.8.0 pydantic-settings-2.0.
Hi @theunkn0wn1,
Thanks for reporting this. I think this might make sense as an addition to pydantic-extra-types
. We'd certainly consider any PRs supporting this change 👍.
@sydney-runkle opened a PR to add this to pydantic-extra-types
.
Fantastic! I'm going to move this issue over there :).
Hi, would it be possible to add the Time object as well?
Hi, would it be possible to add the Time object as well?
probably, PRs are welcome.