🐛 Fix support for `Annotated` fields with Pydantic 2.12+
After pydantic update to support Python 3.14, different declaration syntax were affected by the changed.
I check and on pydantic side there is not changes on the resulting FieldInfo structure, at least at first glance.
In the tests I illustrated the 3 possible declaration syntax for annotations defined by pydantic and supported so far by sqlmodel. Two of them do not work any more with pydantic>=2.12!
@YuriiMotov Hi again! Maybe take a look at this, this is also related with Python 3.14 support and pydantic>=2.12 update.
@YuriiMotov can you label this as a bug?
solves #1602
Any idea on when a new release with this fix will be available?
Any idea on when a new release with this fix will be available?
Not really, hopefully soon!
I would still recommend to use pydantic<2.12 if python 3.14 is not required... there have been big changes recently that could have included some malfunctions like this
Any idea on when a new release with this fix will be available?
Not really, hopefully soon! I would still recommend to use
pydantic<2.12if python 3.14 is not required... there have been big changes recently that could have included some malfunctions like this
That's alright, I'll follow your suggestion. Thanks for the quick reply!
Hi @stickM4N, thanks for the PR! I'm going to push some changes to your branch directly, to include also the tests from #1602 and to get the PR in a good state to merge. I'll put it in draft while I work on it.
Perfect, feel free to do it! It will be nice for this to me merged soon.
FYI PR #1607 works with __future__.annotations as well, whereas this one does not.
FYI PR #1607 works with
__future__.annotationsas well, whereas this one does not.
Can you provide more details on this?
Sure, I tested the following model with both PRs, with and without future annotations in Python 3.13:
class CreateTimeMixin:
create_time: Annotated[AwareDatetime, Field(sa_type=DATETIME_TIMEZONE)]
This PR failed to pick up on the annotated metadata when future annotations were enabled.