(obj)
| 334 | |
| 335 | |
| 336 | def make_msgpack_compatible(obj): |
| 337 | if isinstance(obj, datetime.date): |
| 338 | return obj.isoformat() |
| 339 | if isinstance(obj, array.array): |
| 340 | return obj.tolist() |
| 341 | if is_dataclass(obj): |
| 342 | return { |
| 343 | f.name: make_msgpack_compatible(getattr(obj, f.name)) for f in fields(obj) |
| 344 | } |
| 345 | if isinstance(obj, dict): |
| 346 | return { |
| 347 | make_msgpack_compatible(k): make_msgpack_compatible(v) |
| 348 | for k, v in obj.items() |
| 349 | } |
| 350 | if isinstance(obj, list): |
| 351 | return [make_msgpack_compatible(v) for v in obj] |
| 352 | if isinstance(obj, tuple): |
| 353 | return tuple(make_msgpack_compatible(v) for v in obj) |
| 354 | return obj |
| 355 | |
| 356 | |
| 357 | def _restore_dataclass_from_template(value, template): |
no test coverage detected