Skip to content

fix: migrate 3 response-model class Config blocks to ConfigDict - #311

Closed
dulcetberg wants to merge 1 commit into
hotosm:developfrom
dulcetberg:fix/pydantic-v2-response-model-configs
Closed

dulcetberg wants to merge 1 commit into
hotosm:developfrom
dulcetberg:fix/pydantic-v2-response-model-configs

Conversation

@dulcetberg

Copy link
Copy Markdown
Contributor

Summary

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

These are all simple, example-only Config blocks with no other settings, so the conversion is mechanical. BaseModel's own Config (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 Config blocks flagged as remaining scope for #256.

Test plan

  • pytest tests/test_app.py passes (5 passed)
  • No remaining "class-based config is deprecated" warnings for these 3 classes
  • Confirmed each model's model_json_schema() still includes its example after the conversion

🤖 Generated with Claude Code

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>
@dulcetberg

Copy link
Copy Markdown
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.

@dulcetberg dulcetberg closed this Sep 21, 2026
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.

1 participant