1
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2026-03-04 16:02:51 +01:00

fix: don't sidestep model validation

This commit is contained in:
2026-02-11 10:36:03 +01:00
parent 1534118f21
commit ed86c852cb
5 changed files with 6 additions and 6 deletions

View File

@@ -91,7 +91,7 @@ class AutoUpdates(BECMainWindow):
"""
Callback for scan status messages.
"""
msg = ScanStatusMessage(**content, metadata=metadata)
msg = ScanStatusMessage.model_validate({**content, "metadata": metadata})
if not self.enabled:
return

View File

@@ -152,7 +152,7 @@ class ScanHistoryDeviceViewer(BECWidget, QtWidgets.QWidget):
Args:
msg (ScanHistoryMessage): The scan history message containing device data.
"""
msg = ScanHistoryMessage(**msg)
msg = ScanHistoryMessage.model_validate(msg)
if metadata is not None:
msg.metadata = metadata
# Keep track of current device name

View File

@@ -118,7 +118,7 @@ class ScanHistoryMetadataViewer(BECWidget, QtWidgets.QGroupBox):
Args:
msg (ScanHistoryMessage): The message containing scan metadata.
"""
msg = ScanHistoryMessage(**msg)
msg = ScanHistoryMessage.model_validate(msg)
if metadata is not None:
msg.metadata = metadata
if msg == self.scan_history_msg:

View File

@@ -212,7 +212,7 @@ class ScanHistoryView(BECWidget, QtWidgets.QTreeWidget):
@SafeSlot(dict)
def update_history(self, msg_dump: dict):
"""Update the scan history with new scan data."""
msg = ScanHistoryMessage(**msg_dump)
msg = ScanHistoryMessage.model_validate(msg_dump)
self.add_scan(msg)
self.ensure_history_max_length()
@@ -221,7 +221,7 @@ class ScanHistoryView(BECWidget, QtWidgets.QTreeWidget):
"""Update the scan history with a full list of scan data."""
messages = []
for msg_dump in all_messages:
msg = ScanHistoryMessage(**msg_dump)
msg = ScanHistoryMessage.model_validate(msg_dump)
messages.append(msg)
if len(messages) >= self.max_length:
messages.pop(0)

View File

@@ -104,7 +104,7 @@ class BecLogsQueue(BECConnector, QObject):
@SafeSlot(verify_sender=True)
def _process_incoming_log_msg(self, msg: dict, _metadata: dict):
try:
_msg = LogMessage(**msg)
_msg = LogMessage.model_validate(msg)
self._data.append(_msg)
if self.filter is None or self.filter(_msg):
self._display_queue.append(self._line_formatter(_msg))