You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @ringohoffman - I took a cursory look at upgrading to pydantic v2, it wasn't just a straight upgrade (I had some trouble with the nested configuration models for default configuration) but definitely something that's high on the list!
Reacted by Matthew Hoffman, Andrew Sansom and Martin Picard
Re upgrade: I noticed the following:
After pydantic/pydantic#6722 I realised tomlkit parsed into its own types rather than builtin Python types, and Pydantic V2 isn't coercing them like v1 so it "looks like" valid TOML is invalid according to the Config model.
I tried swapping tomlkit for tomli and tomli-w, as tomli does parse TOML into builtin Python types - however, tomli_w reformatted the TOML file when it was written out. Maybe not the worst crime but I was reluctant to just throw that in. I didn't really want to use two TOML parsing libraries (especially as there's also a builtin one in 3.11+), so need to figure a way out to make all these things work together - hoping there's a "coerce" setting for pydantic v2 models that I've missed
Activity
bernardcooke53 commentedon Jul 19, 2023
Hey @ringohoffman - I took a cursory look at upgrading to pydantic v2, it wasn't just a straight upgrade (I had some trouble with the nested configuration models for default configuration) but definitely something that's high on the list!
bernardcooke53 commentedon Jul 26, 2023
Re upgrade: I noticed the following:
After pydantic/pydantic#6722 I realised
tomlkitparsed into its own types rather than builtin Python types, and Pydantic V2 isn't coercing them like v1 so it "looks like" valid TOML is invalid according to the Config model.I tried swapping
tomlkitfortomliandtomli-w, astomlidoes parse TOML into builtin Python types - however,tomli_wreformatted the TOML file when it was written out. Maybe not the worst crime but I was reluctant to just throw that in. I didn't really want to use two TOML parsing libraries (especially as there's also a builtin one in 3.11+), so need to figure a way out to make all these things work together - hoping there's a "coerce" setting for pydantic v2 models that I've missed