-
Notifications
You must be signed in to change notification settings - Fork 104
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
Migrate to pydantic v2 #452
Comments
I would be open to such a PR :) python-on-whales should be compatible with both versions |
So if i understand correctly, in I found there are mainly two things in the repo that would need to be changed to be able to support both pydantic v1 and v2:
|
Yes
That makes me really sad. Isn't there really any way to recreate it? That would be a massive change to put all field optional.
That's fine by me :) |
Yeah, me too. In my current project we have several pydantic models where we want all the different attributes to be optional, and we went ahead and did it the way i described above. Pydantic v2 is still young, and a lot of the docs has not been updated for the new version yet, so there hopefully might be some way of accomplishing something similar in v2. But if one wants to support both v1 and v2 it seems like there is some breaking changes to the |
With my limited experience with pydantic, I can see some benefit from "explicit over implicit" (this did previously confuse me on a previous contribution to this project). |
A first step: #454 |
Second and last step (hopefully): #455 |
We are currently blocked by pydantic/pydantic#6512 |
Sorry for ghosting you @gabrieldemarmiesse. Vacation and IRL hit hard. Nice to see that you're working on it :) |
No worries. Nobody's in a hurry in open source :) |
IT IS DONE Can you try the latest version of master? I'd like some feedback before an official release Note: pydantic v2.0.x won't work. Please install 2.1.x |
Good job! Did some testing on our test suite, and it seems like python-on-whales worked as it used to before supporting pydantic v2. Only nitpick i have is some deprecation warnings being raised, eg python-on-whales/python_on_whales/components/container/cli_wrapper.py Lines 95 to 96 in e054f1e
PydanticDeprecatedSince20 warning since parse_obj is deprecated. I don't think one can get around things like this if one wants to support pydantic v1 and v2 :)
I was not able to do extensive testing, since my project also needed to support pydantic v2 in order to test this and i had to do some quick and dirty fixes to get things up and running. |
That seems feasible. I'm sure with a if-else on the version we can do that |
you shouldn't have any warnings now, feel free to try the latest master |
Awesome! Tested and got no warnings :) |
The new release is here, feel free to test it and report any bugs. I'll close this issue! |
Hi, and thanks for an awesome library. It has really helped my current project with automating integration- and end-to-end tests using docker compose.
We are looking to migrate to pydantic v2, which python-on-whales does not yet support. This is of course understandable since the first stable pydantic v2 released june 30 (two days when writing this).
If you would like me to submit a PR for this migration i would gladly help :)
The text was updated successfully, but these errors were encountered: