Commit 79ccc39
authored
Auto-convert dicts to EventState in Event (#2061)
## Summary
- Adds `__attrs_post_init__` to `Event` that auto-converts dicts in
`device_states` to `EventState` objects
- Consumers constructing `Event` directly (e.g. in tests) no longer need
to manually wrap dicts as `EventState(**state)`
- Existing cattrs structuring path is unaffected
## Test plan
- [x] All 438 existing tests pass
- [x] Verified direct construction with dicts works: `Event(name=...,
device_states=[{"name": "...", "type": 3, "value": "open"}])`
- [x] Verified passing `EventState` objects directly still works
- [x] Pre-commit hooks pass (ruff, mypy, ty)1 parent d8414e6 commit 79ccc39
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
574 | 579 | | |
575 | 580 | | |
576 | 581 | | |
| |||
0 commit comments