-
Notifications
You must be signed in to change notification settings - Fork 412
Fix after model validator signatures #2626
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
kevinjqliu
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.
Thank you for the fix!
I see this is a breaking change from pydantic/pydantic#11957
I tested this locally with pydantic 2.12.2, and the tests passed
The signature you used wasn't documented anywhere, so more a https://xkcd.com/1172/ than a breaking change. However, I came across several libraries using this signature, so I'm wondering where it came from. |
|
@Viicos looks like we replaced this syntax is still fairly prevalent, https://github.com/search?q=%2F%40model_validator%5C%28mode%3D.*after.*%5C%29%5Cn.*def+.*%5C%28cls%2F&type=code Thanks again for the fix! |
|
Thanks, that would explain why I had some reports using this signature then! The migration guide doesn't properly mention the allowed signatures, so I'll make sure to update it even though the impact is way lower today. |
I also saw this, FYI we are reverting the change in the next 2.12 patch release and adding a deprecation warning instead. |
HonahX
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 fix! I used to wonder why we not just use self in the after validator since the object is already initialized.
Yes this is still the only expected way to use it. Since 2.12.3, a deprecation warning suggesting to use instance methods is emitted when using class methods. |
|
@Viicos Thanks for the fix, this is working well for me. @Fokko and @kevinjqliu can we get this merged?! |
|
Thanks for the fix @Viicos and thank you everyone for the review. As a followup, I'll also take a look at other after model validators. |
…ydantic 2.12.3 (#2635) <!-- Thanks for opening a pull request! --> <!-- In the case this PR will resolve an issue, please replace ${GITHUB_ISSUE_ID} below with the actual Github issue id. --> <!-- Closes #${GITHUB_ISSUE_ID} --> # Rationale for this change Follow up to #2591 Closes #2590 Pydantic released a regression in 2.12.x that was fixed by 2.12.2 and 2.12.3 2.12.2 originally did not work due to incompatible signature that was fixed in #2626 2.12.3 turn the incompatible signature into a deprecation warning. This PR disallows pydantic 2.12.0 and 2.12.1 and update poetry lock to use pydantic 2.12.3 With #2626 merged, pyiceberg should work with both pydantic 2.12.2 and 2.12.3 ## Are these changes tested? Yes, UT. Tested both with pydantic 2.12.2 and 2.12.3 ## Are there any user-facing changes? <!-- In the case of user-facing changes, please add the changelog label. --> No
Rationale for this change
(Partially?) fixes #2590.
See https://pydantic.dev/articles/pydantic-v2-12-release#after-model-validators.
Are these changes tested?
Are there any user-facing changes?