Uh oh!
There was an error while loading. Please reload this page.
🐛 Fix support for Annotated fields with Pydantic 2.12+ - #1603
Conversation
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
stickm4n
commented
Oct 20, 2025
solves #1602 |
Annotated fields with Pydantic 2.12+Uh oh!
There was an error while loading. Please reload this page.
3f6bec5 to
eb3cfccComparewguilen
commented
Oct 22, 2025
Any idea on when a new release with this fix will be available? |
stickm4n
commented
Oct 22, 2025
Not really, hopefully soon! |
wguilen
commented
Oct 22, 2025
That's alright, I'll follow your suggestion. Thanks for the quick reply! |
Annotated fields with Pydantic 2.12+Annotated fields with Pydantic 2.12+ (alternative 1)stickm4n
commented
Oct 30, 2025
Annotated fields with Pydantic 2.12+ (alternative 1)Annotated fields with Pydantic 2.12+
svlandeg
left a comment
There was a problem hiding this comment.
Thanks for the work on this, @stickm4n!
This now looks good to merge to me. I've added in the tests from #1602 just for good measure, and refactored the code a bit using Yurii's suggestions. I think it's much easier to follow/maintain like this, without the continue & break statements.
Will yet run this by Tiangolo for a final review.
Note that another alternative to this PR is #1607 - if we decide to merge this, we can close the other one.
KSmanis
commented
Nov 15, 2025
FYI PR #1607 works with |
stickm4n
commented
Nov 15, 2025
Can you provide more details on this? |
KSmanis
commented
Nov 15, 2025
Sure, I tested the following model with both PRs, with and without future annotations in Python 3.13: classCreateTimeMixin:
create_time: Annotated[AwareDatetime, Field(sa_type=DATETIME_TIMEZONE)]This PR failed to pick up on the annotated metadata when future annotations were enabled. |
sr-verde
commented
Jan 8, 2026
zhcn000000
commented
Jan 31, 2026
merge it soon may be helpful for pydantic 2.12+ |
tiangolo
commented
Feb 1, 2026
Thank you @stickm4n! And thanks everyone for the discussion here. I went with #1607 because that approach, moving the metadata to its own annotation will allow us (in the future) to stop sub-classing I also added a test with stringified annotations ( The fix will be available in the next few hours in SQLModel 0.0.32 🚀 Given that, I'll now close this one. Thanks! ☕ |
After
pydanticupdate to support Python 3.14, different declaration syntax were affected by the changed.I check and on
pydanticside there is not changes on the resultingFieldInfostructure, at least at first glance.In the tests I illustrated the 3 possible declaration syntax for annotations defined by
pydanticand supported so far bysqlmodel. Two of them do not work any more withpydantic>=2.12!