(value, template)
| 355 | |
| 356 | |
| 357 | def _restore_dataclass_from_template(value, template): |
| 358 | if not is_dataclass(template): |
| 359 | return value |
| 360 | if not isinstance(value, dict): |
| 361 | return value |
| 362 | |
| 363 | kwargs = {} |
| 364 | for field in template.__dataclass_fields__.values(): |
| 365 | field_value = value.get(field.name) |
| 366 | template_value = getattr(template, field.name, None) |
| 367 | if is_dataclass(template_value): |
| 368 | kwargs[field.name] = _restore_dataclass_from_template( |
| 369 | field_value, template_value |
| 370 | ) |
| 371 | else: |
| 372 | kwargs[field.name] = field_value |
| 373 | return type(template)(**kwargs) |
| 374 | |
| 375 | |
| 376 | def build_fory_benchmark_case(operation: str, ref: bool, obj): |
no test coverage detected