-
Notifications
You must be signed in to change notification settings - Fork 3k
Python: Bump to Pydantic v2 #7782
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
Changes from all commits
a66a415
8d89a9b
5701bf2
6d730a0
65f3313
07e22d1
d05ab04
e739408
93063c3
176696f
ca65a7a
08ca64e
558aebf
eeed1fa
944316c
da3547c
dcb9d1c
d97c14e
2aa6879
65c6b27
7ebc614
79bab05
7fcb38a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,7 @@ | |
| Union, | ||
| ) | ||
|
|
||
| from pydantic import Field | ||
| from pydantic import Field, SerializeAsAny | ||
| from sortedcontainers import SortedList | ||
|
|
||
| from pyiceberg.expressions import ( | ||
|
|
@@ -365,8 +365,8 @@ class AssertDefaultSortOrderId(TableRequirement): | |
|
|
||
| class CommitTableRequest(IcebergBaseModel): | ||
| identifier: Identifier = Field() | ||
| requirements: List[TableRequirement] = Field(default_factory=list) | ||
| updates: List[TableUpdate] = Field(default_factory=list) | ||
| requirements: List[SerializeAsAny[TableRequirement]] = Field(default_factory=list) | ||
| updates: List[SerializeAsAny[TableUpdate]] = Field(default_factory=list) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you help me understand what's happening here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also had to learn this by raising an issue: pydantic/pydantic#6403 (comment) It turns out that you need to wrap this when you're serializing an object, that might have subclasses. This way it gets correctly serialized. |
||
|
|
||
|
|
||
| class CommitTableResponse(IcebergBaseModel): | ||
|
|
||
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.
Nit: It uses "validate" instead of "parse"? That seems weird to me.
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.
From the migration guide: https://docs.pydantic.dev/latest/migration/

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.
Yeah, it just doesn't seem to describe what the method is doing. It's not a validation. It's producing a different object.
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.
I agree, I would also prefer
parse