Skip to content
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

Merged
merged 4 commits into from
Dec 8, 2023

Conversation

antazoey
Copy link
Member

What I did

Upgrade to pydantic v2

How I did it

follow the migration guide

How to verify it

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

@vany365 vany365 changed the title feat!: pydantic v2 support feat!: pydantic v2 support [APE-1412] Sep 25, 2023
class TraceMemory(BaseModel):
__root__: List[HexBytes] = []
class TraceMemory(RootModel[List[HexBytes]]):
root: List[HexBytes] = []
Copy link
Member Author

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())
Copy link
Member Author

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.

Copy link
Contributor

@NotPeopling2day NotPeopling2day left a 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

@NotPeopling2day NotPeopling2day marked this pull request as ready for review December 8, 2023 18:55
@NotPeopling2day NotPeopling2day enabled auto-merge (squash) December 8, 2023 18:59
@NotPeopling2day NotPeopling2day merged commit 54c0a5e into ApeWorX:main Dec 8, 2023
11 checks passed
@antazoey antazoey deleted the feat/pydantic-v2 branch December 13, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants