Skip to content

Conversation

@Viicos
Copy link
Contributor

@Viicos Viicos commented Oct 14, 2025

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?

Copy link
Contributor

@kevinjqliu kevinjqliu left a 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

@Viicos
Copy link
Contributor Author

Viicos commented Oct 15, 2025

I see this is a breaking change

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.

@kevinjqliu
Copy link
Contributor

@Viicos looks like we replaced root_validator with model_validator and retain the same syntax
https://github.com/apache/iceberg/pull/7782/files#diff-6c71fbd8a334d7330d1be4c2a431ff6293cf46a3f95984c40b740e9f2ccdd744L341-L342

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!

@kevinjqliu kevinjqliu requested a review from Fokko October 15, 2025 19:21
@Viicos
Copy link
Contributor Author

Viicos commented Oct 15, 2025

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.

@Viicos
Copy link
Contributor Author

Viicos commented Oct 17, 2025

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

I also saw this, FYI we are reverting the change in the next 2.12 patch release and adding a deprecation warning instead.

Copy link
Contributor

@HonahX HonahX 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 fix! I used to wonder why we not just use self in the after validator since the object is already initialized.

@Viicos
Copy link
Contributor Author

Viicos commented Oct 17, 2025

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.

@ForeverAngry
Copy link
Contributor

@Viicos Thanks for the fix, this is working well for me. @Fokko and @kevinjqliu can we get this merged?!

@kevinjqliu kevinjqliu merged commit c92c471 into apache:main Oct 19, 2025
17 of 18 checks passed
@kevinjqliu
Copy link
Contributor

kevinjqliu commented Oct 19, 2025

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.
EDIT: looks like the other ones are all using self :)

Fokko pushed a commit that referenced this pull request Oct 20, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upstream Pydantic 2.12.0 has a Regression that will break PyIceberg

4 participants