Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🐛 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

Open
stickm4n wants to merge20 commits intofastapi:main
base:main
Choose a base branch
Loading
fromstickm4n:pydantic-2.12-integration

Conversation

@stickm4n
Copy link

Afterpydantic update to support Python 3.14, different declaration syntax were affected by the changed.
I check and onpydantic side there is not changes on the resultingFieldInfo structure, at least at first glance.
In the tests I illustrated the 3 possible declaration syntax for annotations defined bypydantic and supported so far bysqlmodel. Two of them do not work any more withpydantic>=2.12!

sneakers-the-rat, station70-jason, and mattgiles reacted with thumbs up emojisimonvanlierde, svlandeg, and mattgiles reacted with eyes emoji
@stickm4n

This comment has been minimized.

@stickm4n

This comment was marked as resolved.

@stickm4n
Copy link
Author

solves#1602

svlandeg reacted with thumbs up emoji

@YuriiMotovYuriiMotov changed the titlePydantic 2.12 declaration syntax broken🐛 Fix support forAnnotated fields with Pydantic 2.12+Oct 20, 2025
@YuriiMotovYuriiMotov added the bugSomething isn't working labelOct 20, 2025
@stickm4nstickm4nforce-pushed thepydantic-2.12-integration branch from3f6bec5 toeb3cfccCompareOctober 20, 2025 20:48
@wguilen
Copy link

Any idea on when a new release with this fix will be available?

@stickm4n
Copy link
Author

Any idea on when a new release with this fix will be available?

Not really, hopefully soon!
I would still recommend to usepydantic<2.12 if python 3.14 is not required... there have been big changes recently that could have included some malfunctions like this

@wguilen
Copy link

Any idea on when a new release with this fix will be available?

Not really, hopefully soon! I would still recommend to usepydantic<2.12 if 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!

stickm4n reacted with thumbs up emoji

@svlandegsvlandeg self-assigned thisOct 30, 2025
@svlandegsvlandeg changed the title🐛 Fix support forAnnotated fields with Pydantic 2.12+🐛 Fix support forAnnotated fields with Pydantic 2.12+ (alternative 1)Oct 30, 2025
Copy link
Member

@svlandegsvlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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.

@stickm4n
Copy link
Author

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.

@svlandegsvlandeg marked this pull request as draftOctober 30, 2025 20:57
@svlandegsvlandeg marked this pull request as ready for reviewOctober 30, 2025 21:33
@svlandegsvlandeg changed the title🐛 Fix support forAnnotated fields with Pydantic 2.12+ (alternative 1)🐛 Fix support forAnnotated fields with Pydantic 2.12+Oct 30, 2025
Copy link
Member

@svlandegsvlandeg left a 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.

stickm4n, supermacro, and vimota reacted with thumbs up emojiRelecto reacted with eyes emoji
@svlandegsvlandeg removed their assignmentOct 30, 2025
@KSmanis
Copy link

FYI PR#1607 works with__future__.annotations as well, whereas this one does not.

@stickm4n
Copy link
Author

FYI PR#1607 works with__future__.annotations as well, whereas this one does not.

Can you provide more details on this?

@KSmanis
Copy link

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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@YuriiMotovYuriiMotovYuriiMotov left review comments

@svlandegsvlandegsvlandeg approved these changes

Assignees

No one assigned

Labels

bugSomething isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

SQLModel fails to create DB constraints when using Annotated types after Pydantic 2.12.0

6 participants

@stickm4n@wguilen@KSmanis@svlandeg@YuriiMotov@patrick91

[8]ページ先頭

©2009-2025 Movatter.jp