Repository navigation
fix: migrate 3 response-model class Config blocks to ConfigDict - #311
Closed
dulcetberg wants to merge 1 commit into
Closed
dulcetberg wants to merge 1 commit into
dulcetberg wants to merge 1 commit into
Conversation
Converts the remaining `class Config: json_schema_extra = {...}`
blocks in src/validation/models.py to Pydantic V2's
`model_config = ConfigDict(json_schema_extra={...})`:
- SnapshotResponse
- SnapshotTaskResponse
- StatusResponse
The base BaseModel.Config (alias_generator/populate_by_name/
use_enum_values) is handled separately in hotosm#308 - left untouched here
to keep this PR isolated to the 3 simple example-only blocks.
Verified each model's generated JSON schema still surfaces its
`example` correctly after the conversion, and the deprecation warning
is gone for all 3 classes.
Part of the pydantic v1->v2 migration tracked in hotosm#256.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Brian Bergstrom <dulcetberg@gmail.com>
3 of 13 tasks
Contributor
Author
|
Closing in favour of #315, which migrates the whole file in one commit. Splitting this five ways was a mistake on my part: all five branched from the same commit and edited the same import line, so they could not have been merged independently, and each one left the file half migrated. Sorry for the noise. |
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
Converts the remaining
class Config: json_schema_extra = {...}blocks insrc/validation/models.pyto Pydantic V2'smodel_config = ConfigDict(json_schema_extra={...}):SnapshotResponseSnapshotTaskResponseStatusResponseThese are all simple, example-only
Configblocks with no other settings, so the conversion is mechanical.BaseModel's ownConfig(alias_generator/populate_by_name/use_enum_values) is handled separately in #308 and intentionally left untouched here to keep this PR isolated.This is the last of the
class Configblocks flagged as remaining scope for #256.Test plan
pytest tests/test_app.pypasses (5 passed)model_json_schema()still includes itsexampleafter the conversion🤖 Generated with Claude Code