added ruff code reivew

This commit is contained in:
ykcheungab
2026-09-27 19:21:55 +08:00
parent 07da372204
commit e2ac36269c
110 changed files with 890 additions and 426 deletions
+6 -5
View File
@@ -66,9 +66,10 @@ from __future__ import annotations
import threading
import time
from collections.abc import Callable, Iterable, Sequence
from dataclasses import dataclass, field
from queue import Empty, Full, Queue
from typing import Any, Callable, Iterable, Sequence
from typing import Any
import numpy as np
@@ -155,7 +156,7 @@ class StreamPipeline:
contact: bool = False,
depth: int = 2,
include: Sequence[str] | Iterable[str] = ("image",),
on_frame: Callable[["FrameSnapshot"], None] | None = None,
on_frame: Callable[[FrameSnapshot], None] | None = None,
verbose: bool = False,
fps_window: int = 30,
) -> None:
@@ -189,7 +190,7 @@ class StreamPipeline:
# ------------------------------------------------------------------ ctors
@classmethod
def for_finger_runtime(cls, runtime: Any, **kwargs: Any) -> "StreamPipeline":
def for_finger_runtime(cls, runtime: Any, **kwargs: Any) -> StreamPipeline:
"""Build a pipeline for a ``FingerRuntime`` (capture + UV unroll stage)."""
def produce() -> np.ndarray | None:
@@ -199,7 +200,7 @@ class StreamPipeline:
return cls(runtime.tactile.raw_sensor, produce, **kwargs)
# --------------------------------------------------------------- lifecycle
def start(self) -> "StreamPipeline":
def start(self) -> StreamPipeline:
if self._running:
return self
self._running = True
@@ -232,7 +233,7 @@ class StreamPipeline:
err, self._error = self._error, None
raise err
def __enter__(self) -> "StreamPipeline":
def __enter__(self) -> StreamPipeline:
return self.start()
def __exit__(self, exc_type, exc, tb) -> bool: