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

Pydantic v2 upgrade #8

Merged
merged 5 commits into from
Jan 9, 2025
Merged

Pydantic v2 upgrade #8

merged 5 commits into from
Jan 9, 2025

Conversation

linknum23
Copy link

@linknum23 linknum23 commented Dec 30, 2024

Update to a newer generation of pydantic. Initial changes followed the guide here: https://docs.pydantic.dev/latest/migration/

The major challenge here was pyamplipi's use of pydantic;'s ModelMetaclass and ModelField which were made private by the pydantic devs (for good reasons).

This code has been tested via:

@linknum23 linknum23 force-pushed the pydanticv2-upgrade branch 2 times, most recently from ff25f18 to e902583 Compare January 7, 2025 22:03
@linknum23 linknum23 marked this pull request as ready for review January 7, 2025 22:04
@linknum23 linknum23 requested a review from klay2000 January 8, 2025 17:07
@linknum23
Copy link
Author

@klay2000 can you give this a sanity check? No need to validate this.

Copy link

@klay2000 klay2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally seems fine, I only found a spelling error and an accidental paste in a comment I think?

pyamplipi/__main__.py Outdated Show resolved Hide resolved
pyamplipi/__main__.py Outdated Show resolved Hide resolved
@linknum23 linknum23 requested a review from klay2000 January 8, 2025 18:18
- Optional[] fields need to be initialized to None to actually be parsed as optional
- __fields__  -> model_fields
- json()      -> model_dump_json()
- parse_obj() -> model_validate()
Copy link

@klay2000 klay2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect 🎆

@linknum23 linknum23 merged commit 22a481b into main Jan 9, 2025
6 checks passed
@linknum23 linknum23 deleted the pydanticv2-upgrade branch January 9, 2025 17:04
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