Skip to content

fix: migrate BaseModel to Pydantic V2 ConfigDict - #308

Open
dulcetberg wants to merge 1 commit into
hotosm:developfrom
dulcetberg:fix/pydantic-v2-config-dict
Open

fix: migrate BaseModel to Pydantic V2 ConfigDict#308
dulcetberg wants to merge 1 commit into
hotosm:developfrom
dulcetberg:fix/pydantic-v2-config-dict

Conversation

@dulcetberg

Copy link
Copy Markdown

Summary

Second incremental step on #256 (see #307 for the first) — migrates the shared BaseModel's class-based Config to Pydantic V2's model_config = ConfigDict(...) API.

Branched independently from develop rather than stacked on #307, so this is reviewable/mergeable on its own regardless of #307's status.

All settings keep the same names and behavior (alias_generator, populate_by_name, use_enum_values) — only the syntax moves from a nested class to a single class attribute.

Remaining scope for #256 (per maintainer's review on #307): 8 more @validator usages and 3 more class Config blocks in this same file, planned as further small incremental PRs.

Test plan

  • Verified no class-based-config deprecation warning fires for BaseModel after the change
  • pytest tests/test_app.py — 5 passed, 0 failed

The V1-style class-based Config is deprecated in Pydantic 2.x and
scheduled for removal in V3. Migrates the shared BaseModel's config
to the V2 model_config = ConfigDict(...) API.

All settings (alias_generator, populate_by_name, use_enum_values)
keep the same names and behavior in V2 - only the syntax changes,
from a nested class to a single class attribute holding a dict-like
ConfigDict object.

Verified: no more class-based-config deprecation warning fires for
this class, and the existing test suite still passes (5 passed).

Second incremental PR toward hotosm#256, independent of hotosm#307 (branched
fresh from develop rather than stacked on the unmerged first PR).

Signed-off-by: Brian Bergstrom <dulcetberg@gmail.com>
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