Closed theunkn0wn1 closed 9 months ago
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
.
@theunkn0wn1,
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.
Is pendulum.DateTime
now supported? I'm not seeing a mention of it on the official docs. I also get the following error:
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.
Here is the piece of code that triggers this on my Pydantic class:
import pendulum
created_at: Optional[pendulum.DateTime] = Field(default=None)
Setting arbitrary_types_allowed
on the configuration fixes this issue.
class Config:
arbitrary_types_allowed = True
I made sure that the pydantic-extra-types
package is installed.
UPDATE: I was looking at 2.0 documentation and not the latest 2.9 docs. I see it now. Sorry for the confusion š
Initial Checks
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
Example Code
Python, Pydantic & OS Version