fix mypy errors from types-peewee 4.0 (#24323)

types-peewee 4.0 types model fields precisely, so 17 `type: ignore` comments and 2 `cast(str, ...)` calls are no longer needed. Its stubs type `.namedtuples()` and `.dicts()` queries as returning model instances, so the review cleanup reads namedtuple fields by name and the storage usage query casts its dict rows. `start_time` is declared `DateTimeField` but stores unix timestamps, so two reads cast it like `debug_replay.py` already does. `Export` gets an annotation for the `export_case_id` attribute peewee adds at runtime.
This commit is contained in:
Josh Hawkins
2026-09-14 07:52:23 -05:00
committed by GitHub
parent 5be162a22c
commit 3931ab74a8
12 changed files with 41 additions and 31 deletions
+5 -2
View File
@@ -3,8 +3,10 @@
import logging
import shutil
import threading
from collections.abc import Iterable
from multiprocessing.synchronize import Event as MpEvent
from pathlib import Path
from typing import Any, cast
from peewee import SQL, Case, fn
@@ -191,14 +193,15 @@ class StorageMaintainer(threading.Thread):
stream_usages = {
row["stream_type"]: row["usage"] or 0
for row in (
for row in cast(
Iterable[dict[str, Any]],
Recordings.select(
Recordings.stream_type,
fn.SUM(Recordings.segment_size).alias("usage"),
)
.where(Recordings.camera == camera, Recordings.segment_size != 0)
.group_by(Recordings.stream_type)
.dicts()
.dicts(),
)
}
stream_bandwidths = self.camera_storage_stats.get(camera, {}).get(