From b8d2e5560f1ff9b5ba6382e68ef1468705ab2524 Mon Sep 17 00:00:00 2001 From: haixuanTao Date: Sun, 21 Jul 2024 08:07:53 +0200 Subject: [PATCH] Fix `pylint` warning --- node-hub/opencv-plot/opencv_plot/main.py | 8 ++++---- .../opencv-video-capture/opencv_video_capture/main.py | 4 ++-- node-hub/ultralytics-yolo/ultralytics_yolo/main.py | 6 ++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/node-hub/opencv-plot/opencv_plot/main.py b/node-hub/opencv-plot/opencv_plot/main.py index 6b89026d..bd43469f 100644 --- a/node-hub/opencv-plot/opencv_plot/main.py +++ b/node-hub/opencv-plot/opencv_plot/main.py @@ -1,6 +1,6 @@ import os import argparse -import cv2 +from cv2 import cv2 # Importing cv2 this way remove error warnings`` import numpy as np import pyarrow as pa @@ -13,7 +13,7 @@ RUNNER_CI = True if os.getenv("CI") == "true" else False class Plot: frame: np.array = np.array([]) - bboxes: {} = { + bboxes: dict = { "bbox": np.array([]), "conf": np.array([]), "names": np.array([]), @@ -136,7 +136,7 @@ def main(): channels = 3 storage_type = np.uint8 else: - raise Exception(f"Unsupported image encoding: {encoding}") + raise RuntimeError(f"Unsupported image encoding: {encoding}") image = { "width": np.uint32(arrow_image["width"].as_py()), @@ -164,7 +164,7 @@ def main(): elif event_id == "text": plot.text = event["value"][0].as_py() elif event_type == "ERROR": - raise Exception(event["error"]) + raise RuntimeError(event["error"]) if __name__ == "__main__": diff --git a/node-hub/opencv-video-capture/opencv_video_capture/main.py b/node-hub/opencv-video-capture/opencv_video_capture/main.py index 54e3886a..d74408e5 100644 --- a/node-hub/opencv-video-capture/opencv_video_capture/main.py +++ b/node-hub/opencv-video-capture/opencv_video_capture/main.py @@ -1,6 +1,6 @@ import os import argparse -import cv2 +from cv2 import cv2 # Importing cv2 this way remove error warnings`` import numpy as np import pyarrow as pa @@ -115,7 +115,7 @@ def main(): node.send_output("image", pa.array([image]), event["metadata"]) elif event_type == "ERROR": - raise Exception(event["error"]) + raise RuntimeError(event["error"]) if __name__ == "__main__": diff --git a/node-hub/ultralytics-yolo/ultralytics_yolo/main.py b/node-hub/ultralytics-yolo/ultralytics_yolo/main.py index 023742c8..98b9a981 100644 --- a/node-hub/ultralytics-yolo/ultralytics_yolo/main.py +++ b/node-hub/ultralytics-yolo/ultralytics_yolo/main.py @@ -52,7 +52,7 @@ def main(): channels = 3 storage_type = np.uint8 else: - raise Exception(f"Unsupported image encoding: {encoding}") + raise RuntimeError(f"Unsupported image encoding: {encoding}") image = { "width": np.uint32(arrow_image["width"].as_py()), @@ -68,6 +68,8 @@ def main(): if encoding == "bgr8": frame = frame[:, :, ::-1] # OpenCV image (BGR to RGB) + else: + raise RuntimeError(f"Unsupported image encoding: {encoding}") results = model(frame, verbose=False) # includes NMS @@ -90,7 +92,7 @@ def main(): ) elif event_type == "ERROR": - raise Exception(event["error"]) + raise RuntimeError(event["error"]) if __name__ == "__main__":