ModelDiff class¶
Here's the reference information for the ModelDiff class, with all its
parameters, attributes and methods.
You can import the ModelDiff class directly from pyrmute:
pyrmute.ModelDiff
dataclass
¶
ModelDiff(
model_name,
from_version,
to_version,
added_fields,
removed_fields,
modified_fields,
added_field_info,
unchanged_fields,
)
Contains the difference between two models.
to_markdown
¶
Generate a markdown representation of the diff.
| PARAMETER | DESCRIPTION |
|---|---|
header_depth
|
Base header level (1-6). All headers are relative to this. For example, header_depth=2 makes the title "##" and subsections "###".
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Formatted markdown string showing the differences. |
Example
Source code in src/pyrmute/model_diff.py
to_dict
¶
Convert to a JSON-serializable dictionary.
Converts type objects to their string representation for JSON compatibility.
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Any]
|
Dictionary with all type objects converted to strings. |
Source code in src/pyrmute/model_diff.py
from_models
classmethod
¶
Create a ModelDiff by comparing two Pydantic models.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Name of the model.
TYPE:
|
from_model
|
Source model class.
TYPE:
|
to_model
|
Target model class.
TYPE:
|
from_version
|
Source version string.
TYPE:
|
to_version
|
Target version string.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Self
|
ModelDiff instance with computed differences. |
Source code in src/pyrmute/model_diff.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | |