1313 TypeVar ,
1414)
1515
16- from pydantic import Field , ValidationError , field_validator
16+ from pydantic import ConfigDict , Field , ValidationError , field_validator
1717from pydantic .main import BaseModel
1818from pydicom .datadict import tag_for_keyword
1919from pydicom .dataset import Dataset
@@ -187,8 +187,8 @@ class DICOMObject(BaseModel, DICOMDownloadable):
187187 a DICOM dataset
188188 """
189189
190- class Config :
191- arbitrary_types_allowed = True # allows the use of Dataset type below
190+ # allows the use of Dataset type below
191+ model_config = ConfigDict ( arbitrary_types_allowed = True )
192192
193193 uid : str
194194 data : Dataset
@@ -614,9 +614,8 @@ class Query(BaseModel):
614614 max_study_date : Optional [datetime ] = None
615615 min_study_date : Optional [datetime ] = None
616616 include_fields : Optional [List [str ]] = Field (default_factory = list )
617-
618- class Config :
619- extra = "forbid" # raise ValueError when passing an unknown keyword to init
617+ # raise ValueError when passing an unknown keyword to init
618+ model_config = ConfigDict (extra = "forbid" )
620619
621620 @classmethod
622621 def init_from_query (
@@ -643,7 +642,7 @@ def init_from_query(
643642 this class
644643 """
645644 # remove empty, None and 0 values
646- params = {key : val for key , val in query .dict ().items () if val }
645+ params = {key : val for key , val in query .model_dump ().items () if val }
647646 try :
648647 return cls (** params )
649648 except ValidationError as e :
@@ -672,7 +671,7 @@ def include_fields_check(cls, include_fields, values): # noqa: B902, N805
672671
673672 def to_short_string (self ):
674673 """A more information-dense str repr. For human reading"""
675- filled_fields = {key : val for key , val in self .dict ().items () if val }
674+ filled_fields = {key : val for key , val in self .model_dump ().items () if val }
676675 filled_fields ["query_level" ] = filled_fields ["query_level" ].value
677676 return f"{ type (self ).__name__ } : { filled_fields } "
678677
0 commit comments