Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork782
🐛 Fix support forAnnotated fields with Pydantic 2.12+#1603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
stickm4n commentedOct 20, 2025
solves#1602 |
Annotated fields with Pydantic 2.12+Uh oh!
There was an error while loading.Please reload this page.
3f6bec5 toeb3cfccComparewguilen commentedOct 22, 2025
Any idea on when a new release with this fix will be available? |
stickm4n commentedOct 22, 2025
Not really, hopefully soon! |
wguilen commentedOct 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)
svlandeg left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
stickm4n commentedOct 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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 thecontinue &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 commentedNov 15, 2025
FYI PR#1607 works with |
stickm4n commentedNov 15, 2025
Can you provide more details on this? |
KSmanis commentedNov 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. |
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!