Repository navigation
Remove the Pydantic integration - #21
Merged
Merged
Conversation
UnitAwareModel had to predict how Pydantic maps input keys to fields, and every attempt to close that gap (#17, #18, #19) needed more of Pydantic's internals. Remove the integration, UnitDimension, the pydantic extra, and the mapping options only it used. docs/mappings.md shows how to validate convert_mapping output with Pydantic instead. Closes #20
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.
Summary
Closes #20. Removes the Pydantic integration. Users validate the output of
convert_mappingwith Pydantic or another library instead.The recipe:
The docs say that only paths listed in
reference_unitsare checked, and thatextra="forbid"makes Pydantic reject unknown suffixed keys such asjunk[ps].Evidence
main):from hartreez.pydantic import UnitAwareModelandfrom hartreez import UnitDimensionimport. pytest: 242 passed, 1 skipped.After: both raise
ImportError. pytest: 197 passed, 1 skipped (torch is not installed; the 45 dropped tests are intests/test_pydantic.py). Pyright reports no errors.timestep=20.67 energy=0.0735inau. Withextra="forbid",{"energy[eV]": 1.0, "junk[ps]": 1.0}is rejected at('junk',).convert_mappingbehaves the same: it always passedrecurse=Trueand never setrequire_references.Merge Danger
Door: two-way
Reverting restores the integration. Once a release ships without it, users will have moved to the recipe.
Blast Radius: Pydantic users
hartreez[pydantic],hartreez.pydantic.UnitAwareModelandhartreez.UnitDimensionshipped in v0.1.0 and v0.1.1. Code that uses them breaks on upgrade. The removal is recorded under## Unreleasedin the newCHANGELOG.md, so the next release should be 0.2.0.