Skip to content

Commit 0643389

Browse files
authored
Fix deprecated class Config in pydantic models (#359)
Use ConfigDict instead.
1 parent 84f7875 commit 0643389

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

petab/v2/core.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sympy as sp
1111
from pydantic import (
1212
BaseModel,
13+
ConfigDict,
1314
Field,
1415
ValidationInfo,
1516
field_validator,
@@ -149,9 +150,9 @@ def sympify(cls, v):
149150

150151
return sympify_petab(v)
151152

152-
class Config:
153-
populate_by_name = True
154-
arbitrary_types_allowed = True
153+
model_config = ConfigDict(
154+
arbitrary_types_allowed=True, populate_by_name=True
155+
)
155156

156157

157158
class ObservablesTable(BaseModel):
@@ -224,10 +225,11 @@ class Change(BaseModel):
224225
operation_type: OperationType = Field(alias=C.OPERATION_TYPE)
225226
target_value: sp.Basic | None = Field(alias=C.TARGET_VALUE, default=None)
226227

227-
class Config:
228-
populate_by_name = True
229-
arbitrary_types_allowed = True
230-
use_enum_values = True
228+
model_config = ConfigDict(
229+
arbitrary_types_allowed=True,
230+
populate_by_name=True,
231+
use_enum_values=True,
232+
)
231233

232234
@model_validator(mode="before")
233235
@classmethod
@@ -264,8 +266,7 @@ class ChangeSet(BaseModel):
264266
id: str = Field(alias=C.CONDITION_ID)
265267
changes: list[Change]
266268

267-
class Config:
268-
populate_by_name = True
269+
model_config = ConfigDict(populate_by_name=True)
269270

270271
@field_validator("id")
271272
@classmethod
@@ -354,8 +355,7 @@ class ExperimentPeriod(BaseModel):
354355
start: float = Field(alias=C.TIME)
355356
condition_id: str = Field(alias=C.CONDITION_ID)
356357

357-
class Config:
358-
populate_by_name = True
358+
model_config = ConfigDict(populate_by_name=True)
359359

360360
@field_validator("condition_id")
361361
@classmethod
@@ -378,9 +378,9 @@ class Experiment(BaseModel):
378378
id: str = Field(alias=C.EXPERIMENT_ID)
379379
periods: list[ExperimentPeriod] = []
380380

381-
class Config:
382-
populate_by_name = True
383-
arbitrary_types_allowed = True
381+
model_config = ConfigDict(
382+
arbitrary_types_allowed=True, populate_by_name=True
383+
)
384384

385385
@field_validator("id")
386386
@classmethod
@@ -471,9 +471,9 @@ class Measurement(BaseModel):
471471
alias=C.NOISE_PARAMETERS, default_factory=list
472472
)
473473

474-
class Config:
475-
populate_by_name = True
476-
arbitrary_types_allowed = True
474+
model_config = ConfigDict(
475+
arbitrary_types_allowed=True, populate_by_name=True
476+
)
477477

478478
@field_validator(
479479
"experiment_id",
@@ -566,8 +566,7 @@ class Mapping(BaseModel):
566566
petab_id: str = Field(alias=C.PETAB_ENTITY_ID)
567567
model_id: str = Field(alias=C.MODEL_ENTITY_ID)
568568

569-
class Config:
570-
populate_by_name = True
569+
model_config = ConfigDict(populate_by_name=True)
571570

572571
@field_validator(
573572
"petab_id",
@@ -636,10 +635,11 @@ class Parameter(BaseModel):
636635
estimate: bool = Field(alias=C.ESTIMATE, default=True)
637636
# TODO priors
638637

639-
class Config:
640-
populate_by_name = True
641-
arbitrary_types_allowed = True
642-
use_enum_values = True
638+
model_config = ConfigDict(
639+
arbitrary_types_allowed=True,
640+
populate_by_name=True,
641+
use_enum_values=True,
642+
)
643643

644644
@field_validator("id")
645645
@classmethod

0 commit comments

Comments
 (0)