Sfoglia il codice sorgente

style(event_pusher): correct optional type hints

wenhongquan 1 giorno fa
parent
commit
dfd6a34fc7
1 ha cambiato i file con 5 aggiunte e 5 eliminazioni
  1. 5 5
      dual_camera_system/event_pusher.py

+ 5 - 5
dual_camera_system/event_pusher.py

@@ -11,7 +11,7 @@ import queue
 import tempfile
 import requests
 import mimetypes
-from typing import Optional, Dict, Any, List
+from typing import Optional, Dict, Any, List, Callable
 from dataclasses import dataclass
 from datetime import datetime
 from enum import Enum
@@ -153,7 +153,7 @@ class EventPusher:
         with self.stats_lock:
             self.stats['total_events'] += 1
     
-    def push_safety_violation(self, description: str, image: np.ndarray = None,
+    def push_safety_violation(self, description: str, image: Optional[np.ndarray] = None,
                               track_id: int = 0, confidence: float = 0.0,
                               location: str = "施工现场") -> bool:
         """
@@ -186,7 +186,7 @@ class EventPusher:
         self.push_event(event)
         return True
     
-    def upload_numpy_image(self, image: np.ndarray) -> Optional[str]:
+    def upload_numpy_image(self, image: Optional[np.ndarray]) -> Optional[str]:
         """
         将 numpy 图片上传到 OSS
         
@@ -497,10 +497,10 @@ class EventListener:
             if self.on_other_command:
                 self.on_other_command(cmd)
     
-    def set_voice_callback(self, callback):
+    def set_voice_callback(self, callback: Optional[Callable[[Dict[str, Any]], None]]):
         """设置语音播放回调"""
         self.on_voice_command = callback
     
-    def set_other_callback(self, callback):
+    def set_other_callback(self, callback: Optional[Callable[[Dict[str, Any]], None]]):
         """设置其他指令回调"""
         self.on_other_command = callback