From 3020b400ed69b2d22dd1f60e063e0a510018ea93 Mon Sep 17 00:00:00 2001 From: Pouzor Date: Sat, 27 Jun 2026 14:29:22 +0200 Subject: [PATCH] fix: declare transient node timestamp attrs on PendingDevice mypy flagged the per-request node_* timestamp attributes as undefined on the model. Declare them as class-level defaults (like canvas_count) and set __allow_unmapped__ so SQLAlchemy 2.0 doesn't try to map the Optional[datetime] annotations as columns. --- backend/app/db/models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/app/db/models.py b/backend/app/db/models.py index 9209b2b..f749cc7 100644 --- a/backend/app/db/models.py +++ b/backend/app/db/models.py @@ -100,6 +100,9 @@ class CanvasState(Base): class PendingDevice(Base): __tablename__ = "pending_devices" + # Permit the plain (non-Mapped[]) annotations on the transient request-only + # attributes below; without this SQLAlchemy 2.0 tries to map them as columns. + __allow_unmapped__ = True id: Mapped[str] = mapped_column(String, primary_key=True, default=_uuid) ip: Mapped[str | None] = mapped_column(String, nullable=True) @@ -121,6 +124,12 @@ class PendingDevice(Base): # Transient (not persisted): populated per-request by the scan routes to report # how many canvases this device already appears on. Not a mapped column. canvas_count: int = 0 + # Transient (not persisted): timestamps from the linked canvas node(s), + # correlated by ip / ieee_address. None when the device is not on any canvas. + node_created_at: datetime | None = None + node_last_scan: datetime | None = None + node_last_modified: datetime | None = None + node_last_seen: datetime | None = None class PendingDeviceLink(Base):