@@ -106,24 +106,24 @@ class DiffSyncModel(BaseModel):
106106 """Message, if any, associated with the create/update/delete status value."""
107107 model_config = ConfigDict (arbitrary_types_allowed = True )
108108
109- def __init_subclass__ (cls ) -> None :
109+ @classmethod
110+ def __pydantic_init_subclass__ (cls , ** kwargs : Any ) -> None :
110111 """Validate that the various class attribute declarations correspond to actual instance fields.
111112
112113 Called automatically on subclass declaration.
113114 """
114- variables = cls .__fields__ .keys ()
115115 # Make sure that any field referenced by name actually exists on the model
116116 for attr in cls ._identifiers :
117- if attr not in variables and not hasattr (cls , attr ):
117+ if attr not in cls . model_fields and not hasattr (cls , attr ):
118118 raise AttributeError (f"_identifiers { cls ._identifiers } references missing or un-annotated attr { attr } " )
119119 for attr in cls ._shortname :
120- if attr not in variables :
120+ if attr not in cls . model_fields :
121121 raise AttributeError (f"_shortname { cls ._shortname } references missing or un-annotated attr { attr } " )
122122 for attr in cls ._attributes :
123- if attr not in variables :
123+ if attr not in cls . model_fields :
124124 raise AttributeError (f"_attributes { cls ._attributes } references missing or un-annotated attr { attr } " )
125125 for attr in cls ._children .values ():
126- if attr not in variables :
126+ if attr not in cls . model_fields :
127127 raise AttributeError (f"_children { cls ._children } references missing or un-annotated attr { attr } " )
128128
129129 # Any given field can only be in one of (_identifiers, _attributes, _children)
@@ -147,15 +147,15 @@ def dict(self, **kwargs: Any) -> Dict:
147147 """Convert this DiffSyncModel to a dict, excluding the diffsync field by default as it is not serializable."""
148148 if "exclude" not in kwargs :
149149 kwargs ["exclude" ] = {"diffsync" }
150- return super ().dict (** kwargs )
150+ return super ().model_dump (** kwargs )
151151
152152 def json (self , ** kwargs : Any ) -> StrType :
153153 """Convert this DiffSyncModel to a JSON string, excluding the diffsync field by default as it is not serializable."""
154154 if "exclude" not in kwargs :
155155 kwargs ["exclude" ] = {"diffsync" }
156156 if "exclude_defaults" not in kwargs :
157157 kwargs ["exclude_defaults" ] = True
158- return super ().json (** kwargs )
158+ return super ().model_dump_json (** kwargs )
159159
160160 def str (self , include_children : bool = True , indent : int = 0 ) -> StrType :
161161 """Build a detailed string representation of this DiffSyncModel and optionally its children."""
@@ -855,4 +855,4 @@ def count(self, model: Union[StrType, "DiffSyncModel", Type["DiffSyncModel"], No
855855
856856
857857# DiffSyncModel references DiffSync and DiffSync references DiffSyncModel. Break the typing loop:
858- DiffSyncModel .update_forward_refs ()
858+ DiffSyncModel .model_rebuild ()
0 commit comments