-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat!: pydantic v2 support [APE-1412] #55
Conversation
class TraceMemory(BaseModel): | ||
__root__: List[HexBytes] = [] | ||
class TraceMemory(RootModel[List[HexBytes]]): | ||
root: List[HexBytes] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still defined root
here because that was the only way to make it default to empty list when it got used in other models.
@@ -34,7 +34,7 @@ | |||
def test_parity(name): | |||
assert name in EXPECTED_OUTPUT_MAP, f"Missing expected output set for '{name}'." | |||
path = DATA_PATH / f"{name}.json" | |||
traces = ParityTraceList.parse_file(path) | |||
traces = ParityTraceList.model_validate_json(path.read_text()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love that Pydantic V2 avoids clobbering the model's namespace by prefixing all their methods with model_
.
One might think that is a bad design to have methods with those types of names, but honestly, it is bad design to clobber namespaces. Props to Pydantic v2.
90aa4c7
to
ec12a08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
What I did
Upgrade to pydantic v2
How I did it
follow the migration guide
How to verify it
Checklist