-
Notifications
You must be signed in to change notification settings - Fork 418
Fix deepcopy of primitive types #857
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
0aba3ac to
dc42e88
Compare
dc42e88 to
a68add0
Compare
sungwy
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.
This is really cool 🔥 - thank you for putting in this bug fix so quickly!
This is a nit: I think we could add a test to test_metadata.py to deepcopy a TableMetadata object and ensure that the output is equal to the original one with a Schema representation that contains a mix of the issue affected types.
Theoretically this will work, but its never a bad thing to add an explicit test to demonstrate that the issue is resolved. But other than that, this looks great! Such a speedy resolution of a rather opaque issue 🚀
|
Thank you, @syun64. I have added the test and used an existing metadata definition to avoid duplication. Regarding the solution, to be honest, it was not quick. It took me several weeks of learning and then stepping away from the problem for a few weeks to return with fresh ideas on how to solve it. |
5bad46b to
db8b151
Compare
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.
Thanks for addressing this 🐛!
db8b151 to
4fb7090
Compare
4fb7090 to
76127a5
Compare
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.
LGTM!
@syun64 wdyt
sungwy
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.
Yep! Fantastic fix 💯
|
@ndrluis Thanks for pinging me here. This approval should be gone once the first PR has been merged. Which should be soon 🚀 |
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 great fix!
This approval should be gone once the first PR has been merged.
@Fokko I might have lost track. Which PR are you referring to as the first one?
|
Thanks @ndrluis for working on this, and @syun64, @kevinjqliu and @HonahX for the quick review 🚀 |

The IcebergRootModel inherits from Pydantic RootModel, which has its own implementation of deepcopy. When deepcopy runs, it calls this
__deepcopy__method and ignores that it's a Singleton. So, my solution was to change the order of inheritance and implement a__deepcopy__method for singletons that returns itself.https://github.com/pydantic/pydantic/blob/f024d03b832d1bbcbadf76184ed14d92571a71ca/pydantic/root_model.py#L108-L116