fix: migrate GeometryValidatorMixin to Pydantic V2 field_validator - #307
Open
dulcetberg wants to merge 1 commit into
Open
fix: migrate GeometryValidatorMixin to Pydantic V2 field_validator#307dulcetberg wants to merge 1 commit into
dulcetberg wants to merge 1 commit into
Conversation
The V1-style @validator decorator is deprecated in Pydantic 2.x and scheduled for removal in V3. Migrates GeometryValidatorMixin's geometry validator to the V2 @field_validator API, adding the explicit @classmethod that V2 requires (V1 handled this implicitly). Validator logic is unchanged. Verified: no PydanticDeprecatedSince20 warning fires for this validator anymore, and the existing test suite still passes (5 passed). Part of incremental migration for hotosm#256 - other validators/Field(example=) usages in this file still need converting in follow-up PRs. Signed-off-by: Brian Bergstrom <dulcetberg@gmail.com>
Member
|
Thanks for starting this =) On a basic search I see another usage of Pydantic v2 also deprecates usage of There may be other things too |
Author
|
I already scoped the remaining validators (lines 207, 236, 333, 372, 431, 452, 558, 674) and the 4 |
This was referenced Aug 22, 2026
Member
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
First incremental step on #256 — migrates
GeometryValidatorMixin'sgeometryvalidator from the deprecated Pydantic V1@validatorAPI to V2's@field_validator, adding the explicit@classmethodthat V2 requires (V1 handled this implicitly).Validator logic itself is unchanged — only the decorator mechanics.
This repo currently resolves Pydantic 2.12.3, and the old
@validatorsyntax still works but raisesPydanticDeprecatedSince20warnings, with removal planned for Pydantic V3. This PR is scoped to just this one validator, per the plan discussed in the issue — 8 more@validatorusages remain insrc/validation/models.pyfor follow-up PRs, along with a relatedField(..., example=...)→Field(..., json_schema_extra={...})deprecation pattern noticed while testing.Test plan
PydanticDeprecatedSince20warning fires for this validator after the change (previously did)pytest tests/test_app.py— 5 passed, 0 failed (remaining warnings are all from the other, not-yet-migrated validators/Fields in this file, unrelated to this change)RawDataCurrentParamsBase(BaseModel, GeometryValidatorMixin)), matching how this class is actually usedCloses part of #256 (first of several incremental PRs).