Use pydantic models to represent minecraft-data#23
Draft
Conversation
Open
ItsDrike
added a commit
that referenced
this pull request
Aug 8, 2025
ItsDrike
added a commit
that referenced
this pull request
Aug 8, 2025
c8bcc22 to
083198e
Compare
ItsDrike
added a commit
that referenced
this pull request
Aug 10, 2025
083198e to
8c73200
Compare
ItsDrike
added a commit
that referenced
this pull request
Aug 10, 2025
f289469 to
d9c0205
Compare
ItsDrike
added a commit
that referenced
this pull request
Aug 10, 2025
d9c0205 to
3268792
Compare
ItsDrike
added a commit
that referenced
this pull request
Aug 10, 2025
3268792 to
2c87df9
Compare
2c87df9 to
e043fcd
Compare
0d3251b to
132947d
Compare
22797b0 to
6cd586b
Compare
6cd586b to
4aa0bd9
Compare
4aa0bd9 to
03cb56a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses: #6
This PR moves away from using simple
dictobjects in favor of custom typed pydantic V2 models. This provides us with validation that the individual instances each follow the expected structure (which was designed based on the JSON schemas), and allows users to rely on the auto-completion features of their editor to get the data they're interested in.This also remaps all camelCase fields to snake_case to follow idiomatic python conventions.
Warning
This is a breaking change, since:
load_common_datanow returns a customCommonDataobject, instead of adict.load_versionnow returns a customVersionDataobject, instead of adict.The custom objects are not backwards compatible with
dict(No__getitem__support, camelCase fields were converted to snake_case)This PR also introduces 2 new runtime dependencies:
pydantic(for the model classes with automated conversion from a dict and field validations)eval_type_backport(to allow using modern type annotations with pydantic fields)