Upgrade to Pydantic v2#7
Merged
Merged
Conversation
- Update pydantic dependency constraint from <2.0.0 to >=2.0.0 - parse_raw() -> model_validate_json() - parse_obj() -> model_validate() - Add default=None to Optional duration field on MediaInfo All 16 tests pass with Pydantic 2.12.5. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
johndagostino
approved these changes
Mar 11, 2026
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.
Motivation and Context
wistiapy currently pins
pydantic>=1.8.2,<2.0.0, which blocks any project using Pydantic v2 from depending on this library. Since Pydantic v1 is end-of-life and our main application (and many of our other dependencies) have moved to Pydantic v2, this upgrade unblocks that constraint.Description
Migrates the wistiapy webhook models from Pydantic v1 APIs to Pydantic v2 equivalents. The changes are minimal and targeted:
Dependency constraint (
pyproject.toml):pydantic>=1.8.2,<2.0.0topydantic>=2.0.0- drops v1 support entirely in favour of v2.Model fixes (
wistia/webhooks.py):MediaInfo.duration: Optional[float]changed toOptional[float] = None- Pydantic v2 requires Optional fields to have an explicit default value.EventDelivery.parse_raw(event_data)replaced withEventDelivery.model_validate_json(event_data)-parse_rawwas removed in Pydantic v2.Test updates (
tests/test_webhooks.py):MediaUpdatedEvent.parse_obj(...)replaced withMediaUpdatedEvent.model_validate(...)-parse_objwas removed in Pydantic v2.Design Review
Documentation
This is a dependency version bump with no API surface changes for consumers of the library.
Automated Testing
All 16 existing tests pass on Pydantic v2 with the updated API calls.
Sensitive Data Masking
How Has This Been Manually Tested?
uv run python -m pytest tests/ -v- all 16 tests pass.Backwards Compatibility
<2.0.0upper bound is removed and replaced with>=2.0.0. Any consumer of this library must be on Pydantic v2.parse_webhook_event_delivery, model classes,validate_webhook_signatureetc. all remain identical).0.1.0to signal the breaking dependency change. Will need a PyPI release once merged.