From ebf4e43ced7333fba1a1f0a3b5da84f3f152e2f0 Mon Sep 17 00:00:00 2001 From: Sebastian Englbrecht Date: Sat, 16 Apr 2022 17:38:07 +0200 Subject: [PATCH] Modernizing Typing All Dict, List were converted to dict, list, see: https://mypy.readthedocs.io/en/stable/builtin_types.html#generic-types --- frigate/edgetpu.py | 3 +-- frigate/object_processing.py | 8 ++++---- frigate/video.py | 5 ++--- frigate/watchdog.py | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/frigate/edgetpu.py b/frigate/edgetpu.py index 9849f8afc..cc4b073fb 100644 --- a/frigate/edgetpu.py +++ b/frigate/edgetpu.py @@ -6,7 +6,6 @@ import queue import signal import threading from abc import ABC, abstractmethod -from typing import Dict import numpy as np import tflite_runtime.interpreter as tflite @@ -110,7 +109,7 @@ class LocalObjectDetector(ObjectDetector): def run_detector( name: str, detection_queue: mp.Queue, - out_events: Dict[str, mp.Event], + out_events: dict[str, mp.Event], avg_speed, start, model_path, diff --git a/frigate/object_processing.py b/frigate/object_processing.py index 3742cb7f2..adf1556d5 100644 --- a/frigate/object_processing.py +++ b/frigate/object_processing.py @@ -11,7 +11,7 @@ import threading import time from collections import Counter, defaultdict from statistics import mean, median -from typing import Callable, Dict +from typing import Callable import cv2 import numpy as np @@ -362,9 +362,9 @@ class CameraState: self.config = config self.camera_config = config.cameras[name] self.frame_manager = frame_manager - self.best_objects: Dict[str, TrackedObject] = {} + self.best_objects: dict[str, TrackedObject] = {} self.object_counts = defaultdict(int) - self.tracked_objects: Dict[str, TrackedObject] = {} + self.tracked_objects: dict[str, TrackedObject] = {} self.frame_cache = {} self.zone_objects = defaultdict(list) self._current_frame = np.zeros(self.camera_config.frame_shape_yuv, np.uint8) @@ -650,7 +650,7 @@ class TrackedObjectProcessor(threading.Thread): self.video_output_queue = video_output_queue self.recordings_info_queue = recordings_info_queue self.stop_event = stop_event - self.camera_states: Dict[str, CameraState] = {} + self.camera_states: dict[str, CameraState] = {} self.frame_manager = SharedMemoryFrameManager() def start(camera, obj: TrackedObject, current_frame_time): diff --git a/frigate/video.py b/frigate/video.py index c51f7cf2d..c16d0fe74 100755 --- a/frigate/video.py +++ b/frigate/video.py @@ -9,7 +9,6 @@ import subprocess as sp import threading import time from collections import defaultdict -from typing import Dict, List import numpy as np from cv2 import cv2, reduce @@ -476,8 +475,8 @@ def process_frames( object_detector: RemoteObjectDetector, object_tracker: ObjectTracker, detected_objects_queue: mp.Queue, - process_info: Dict, - objects_to_track: List[str], + process_info: dict, + objects_to_track: list[str], object_filters, detection_enabled: mp.Value, stop_event, diff --git a/frigate/watchdog.py b/frigate/watchdog.py index f593ae066..da514e760 100644 --- a/frigate/watchdog.py +++ b/frigate/watchdog.py @@ -8,13 +8,13 @@ import signal from frigate.edgetpu import EdgeTPUProcess from frigate.util import restart_frigate from multiprocessing.synchronize import Event -from typing import Dict +from typing import dict logger = logging.getLogger(__name__) class FrigateWatchdog(threading.Thread): - def __init__(self, detectors: Dict[str, EdgeTPUProcess], stop_event: Event): + def __init__(self, detectors: dict[str, EdgeTPUProcess], stop_event: Event): threading.Thread.__init__(self) self.name = "frigate_watchdog" self.detectors = detectors