PolicyEngine / PolicyEngine/policyengine-core

Pydantic deprecation warning: class-based config should use ConfigDict

Open
#385 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
22
Forks
30
Avg merge
14h 33m
Merged PRs (30d)
7

Description

Description

When running tests with Pydantic 2.x, we get deprecation warnings:

PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. 
Deprecated in Pydantic V2.0 to be removed in V3.0. 
See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.11/migration/

Location

The warning occurs at:
/policyengine_core/commons/formulas.py (exact location needs to be determined)

Impact

  • Currently just a warning
  • Will break when Pydantic 3.0 is released
  • Shows up in all test runs

Solution

Update any Pydantic models using class-based config to use ConfigDict instead.

Example migration:

# Old style
class MyModel(BaseModel):
    class Config:
        arbitrary_types_allowed = True

# New style
from pydantic import ConfigDict

class MyModel(BaseModel):
    model_config = ConfigDict(arbitrary_types_allowed=True)

Found in

PolicyEngine UK tests running on Python 3.13 with policyengine-core 3.19.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with policyengine_core/commons/formulas.py and identify the Pydantic models using class-based Config. Consult the linked Pydantic V2 migration guidance, update each affected model to ConfigDict, and run the test suite to confirm the deprecation warnings are gone.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.