refactor(occupancy): response model typing, callback signatures, and holiday request schema hygiene #229

Open
opened 2026-10-03 07:23:15 +00:00 by gabogg · 0 comments
Owner

Follow-up for PR #177 (next-day settings activation, #114) addressing pass-3 review findings P3-E, P3-F, P3-H, and P3-I:

Scope

  1. Result Model Dict Shims & Types (P3-E): Result models carry __getitem__/get dict shims "for test callers", which acts as a back door around §2.3. Replace with direct attribute access across test callers. Use PendingChangeType / Literals for status and change_type. Add typed payload models for pending changes.
  2. Callback Typing (P3-F): In occupancy_service.py, reeval_callback: Any should be typed as Callable[[aiosqlite.Connection, float], Awaitable[None]] | None.
  3. Unused Parameter (P3-H): now_epoch is currently unused in get_trusted_calibration_history_conn_async, making now_epoch on multiplier refresh redundant. Either implement the boundary cutoff or remove the dead parameter.
  4. Holiday Schema Separation (P3-I): HolidayItem is currently used as the POST body schema but carries response-only fields (status, pending_change_id, notice_*), allowing clients to send these fields which are then stored in pending payloads. Separate into distinct request (HolidayCreateRequest) and response models.

Acceptance Criteria

  • Result models do not implement dict shims (__getitem__/get); callers access attributes directly.
  • reeval_callback signature is typed as Callable[[aiosqlite.Connection, float], Awaitable[None]] | None.
  • HolidayItem request schema excludes response-only attributes (status, pending_change_id, notice_*).
  • now_epoch in repository calibration query is either active or cleaned up cleanly.

Refs #177, #114.

Follow-up for PR #177 (next-day settings activation, #114) addressing pass-3 review findings P3-E, P3-F, P3-H, and P3-I: ### Scope 1. **Result Model Dict Shims & Types (P3-E)**: Result models carry `__getitem__`/`get` dict shims "for test callers", which acts as a back door around §2.3. Replace with direct attribute access across test callers. Use `PendingChangeType` / Literals for `status` and `change_type`. Add typed payload models for pending changes. 2. **Callback Typing (P3-F)**: In `occupancy_service.py`, `reeval_callback: Any` should be typed as `Callable[[aiosqlite.Connection, float], Awaitable[None]] | None`. 3. **Unused Parameter (P3-H)**: `now_epoch` is currently unused in `get_trusted_calibration_history_conn_async`, making `now_epoch` on multiplier refresh redundant. Either implement the boundary cutoff or remove the dead parameter. 4. **Holiday Schema Separation (P3-I)**: `HolidayItem` is currently used as the POST body schema but carries response-only fields (`status`, `pending_change_id`, `notice_*`), allowing clients to send these fields which are then stored in pending payloads. Separate into distinct request (`HolidayCreateRequest`) and response models. ### Acceptance Criteria - Result models do not implement dict shims (`__getitem__`/`get`); callers access attributes directly. - `reeval_callback` signature is typed as `Callable[[aiosqlite.Connection, float], Awaitable[None]] | None`. - `HolidayItem` request schema excludes response-only attributes (`status`, `pending_change_id`, `notice_*`). - `now_epoch` in repository calibration query is either active or cleaned up cleanly. Refs #177, #114.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gabogg/hikcentral#229
No description provided.