-
-
Notifications
You must be signed in to change notification settings - Fork 64
Upgrade to Pydantic v2 #1214
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
base: master
Are you sure you want to change the base?
Upgrade to Pydantic v2 #1214
Conversation
|
Thanks VB! Like 2 years ago I took a stab at updating our admittedly complex RP build process to pydantic 2.... And everything broke very badly. I'll dig up my old branch and compare notes, hopefully get this working pretty soon. There's complexity in our config broadcast system for item models, to prevent repeating the same lines in config for every item variant. |
|
Here's the manifest generated by the release build on my machine |
|
Alright, the manifests don't match. All modules hashes are different. All --- a/baseline/gm4_bat_grenades_1_21_5/pack.mcmeta
+++ b/baseline/gm4_bat_grenades_1_21_5/pack.mcmeta
@@ -1,6 +1,13 @@
{
"pack": {
- "pack_format": 71,
+ "min_format": [
+ 88,
+ 0
+ ],
+ "max_format": [
+ 88,
+ 0
+ ],
"description": [
"Bat Grenades",
"\n",
@@ -9,11 +16,12 @@
"color": "#4AA0C7"
}
],
+ "pack_format": 71,
"supported_formats": {
"min_inclusive": 71,
"max_inclusive": 81
}
},
"version": "1.6.0",
- "commit_hash": "cb0fe4537"
+ "commit_hash": "14118d19"
}The added All png files have changes. The png files are visually identical but the new python/pillow version probably changed the encoding/compression slightly. All structure files have changes. The nbt data is the same, but again the files likely differ due to minor adjustments in python's compression libraries. Some changes to Some changes in most item models. It looks like it's fixing a potential issue where you currently get redundant entries? For example the previous version of --- a/baseline/gm4_resource_pack_1_21_5/assets/minecraft/items/player_head.json
+++ b/baseline/gm4_resource_pack_1_21_5/assets/minecraft/items/player_head.json
@@ -162,7 +162,7 @@
"model": {
"type": "minecraft:player_head"
},
- "base": "gm4_metallurgy:block/mould/hot_metal"
+ "base": "gm4_metallurgy:block/mould/cool_empty"
}
},
{
@@ -172,7 +172,7 @@
"model": {
"type": "minecraft:player_head"
},
- "base": "gm4_metallurgy:block/mould/hot_metal"
+ "base": "gm4_metallurgy:block/mould/hot_empty"
}
},
{
@@ -182,7 +182,7 @@
"model": {
"type": "minecraft:player_head"
},
- "base": "gm4_metallurgy:block/mould/hot_metal"
+ "base": "gm4_metallurgy:block/mould/cool_metal"
}
},
{That's all the changes I gathered from the |
|
@vberlier What's the status of the |
|
@misode this branch will also need some heavy work from me I suspect. The RP relies on pydantic features quite a bit and will need some validators rewritten in the pydanticv2 paradigm. |
|
@misode The But I'm probably only going to wait for a few more weeks. Projects that rely heavily on pydantic need to try switching to the @SpecialBuilder32 In this PR I already rewrote your models and validators to make everything work with pydantic v2. As I noted earlier, there are a some minor changes in the compiled output, but those are either inconsequential or appear to actually fix a potential bug in the previous implementation. But you'll probably want to re-do some things your way, or at least double check that everything still works as expected and merge this PR as-is until you can take some time to revisit things and maybe do a more extensive revamp to leverage pydantic v2 more idiomatically. |
…into pr/vberlier/1214
I hadn't tried this PR before merging in master, but it doesn't work for me. The Pygantic validators for |
Beet is upgrading to Pydantic v2. I wanted to make sure that the changes on the
betabranch don't break anything so I decided to try to build gm4 with it. And with this PR I'm successfully building everything:$ uv run beet -p beet-release.yamlThe
devcommand seems to work as well.Nearly all of the changes I had to make were related to Pydantic. Some things to note:
overlay_formatsisNone). This is most likely from recent changes on beet's main branch that weren't accounted for in gm4 yet.skin_cache.jsongot updated, not sure why?Nonedefault values.TemplateOptions,TransformOptions, andContainerGuiOptionsto a sort of dynamic discriminated union.serialize_as_any=True.ValidationErrorchanged and I couldn't easily convert the code responsible for aggregating and prefixing errors fromNestedModelDatavalidation. Now, if there are errors, only the first one is shown.Feel free to polish this up, or just use the PR as a guide and completely re-do things your way.