added ruff test

This commit is contained in:
ykcheungab
2026-09-27 19:20:43 +08:00
parent bcab2790bf
commit fa2703968e
178 changed files with 3277 additions and 1034 deletions
@@ -2,13 +2,12 @@
from __future__ import annotations
from orisys_app_shared.i18n import t
from orisys_app_shared.paths import logo_topbar_path
from PySide6.QtCore import Qt
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import QDialog, QHBoxLayout, QLabel, QPushButton, QVBoxLayout
from orisys_app_shared.i18n import t
from orisys_app_shared.paths import logo_topbar_path
from orisys_studio import __version__ as app_version
@@ -10,9 +10,14 @@ where the picture comes from (live / replay), which words the footer.
from __future__ import annotations
from typing import Optional
from PySide6.QtCore import QSize, Qt, Signal
from orisys_app_shared.acquisition.image_backend import (
ARROW_PURE,
ARROW_STITCHED,
DEPTH,
ImagePlan,
)
from orisys_app_shared.i18n import t
from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import QImage, QPainter, QPixmap, QTransform
from PySide6.QtWidgets import (
QComboBox,
@@ -23,15 +28,6 @@ from PySide6.QtWidgets import (
QVBoxLayout,
)
from orisys_app_shared.acquisition.image_backend import (
ARROW_PURE,
ARROW_STITCHED,
DEPTH,
ImagePlan,
)
from orisys_app_shared.i18n import t
from orisys_app_shared.theme import color
from orisys_studio.ui.fit_text import ShrinkableLabel
VIEW_MODES = (ARROW_PURE, ARROW_STITCHED, DEPTH)
@@ -340,7 +336,7 @@ class ArrowPanel(QFrame):
self._placeholder = self._empty_message()
self.image_label.setText(self._placeholder)
def set_plan(self, plan: Optional[ImagePlan]) -> None:
def set_plan(self, plan: ImagePlan | None) -> None:
"""Adopt what the frame on screen can be shown as.
The modes come from the frame's own fields (see ``image_backend.plan_image``),
@@ -14,13 +14,12 @@ from __future__ import annotations
import logging
from pathlib import Path
from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import QColor, QPainter, QPixmap
from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QPushButton, QVBoxLayout
from orisys_app_shared.i18n import t
from orisys_app_shared.paths import logo_topbar_path
from orisys_app_shared.theme import color
from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import QColor, QPainter, QPixmap
from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QPushButton, QVBoxLayout
logger = logging.getLogger(__name__)
+6 -13
View File
@@ -3,6 +3,12 @@
from __future__ import annotations
import numpy as np
from orisys_app_shared.force.calibration_io import (
ChannelKey,
)
from orisys_app_shared.i18n import t
from orisys_app_shared.paths import calibration_export_dir
from orisys_app_shared.theme import color
from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import QColor, QFont, QFontDatabase
from PySide6.QtWidgets import (
@@ -28,19 +34,6 @@ from PySide6.QtWidgets import (
QWidget,
)
from orisys_app_shared.force.calibration_io import (
CalSample,
CalSessionStore,
ChannelKey,
meta_from_sensor_json,
)
from orisys_app_shared.force.calibration_session import (
session_filename,
)
from orisys_app_shared.i18n import t
from orisys_app_shared.paths import calibration_export_dir
from orisys_app_shared.theme import color
from orisys_studio.calibration_service import CalibrationService
from orisys_studio.ui.cal_point_dialog import CalibrationPointDialog
@@ -7,7 +7,8 @@ the three-panel layout, while a single point can still be examined in full.
from __future__ import annotations
import numpy as np
from PySide6.QtCore import Qt
from orisys_app_shared.i18n import t
from orisys_app_shared.theme import color
from PySide6.QtGui import QFont, QFontDatabase
from PySide6.QtWidgets import (
QDialog,
@@ -17,10 +18,6 @@ from PySide6.QtWidgets import (
QVBoxLayout,
)
from orisys_app_shared.force import NA
from orisys_app_shared.i18n import t
from orisys_app_shared.theme import color
try:
import pyqtgraph as pg
except ImportError as exc: # pragma: no cover
+12 -13
View File
@@ -5,16 +5,6 @@ from __future__ import annotations
import time
import numpy as np
from PySide6.QtCore import Qt, QSize, Signal
from PySide6.QtGui import QColor, QFont, QFontDatabase, QFontMetrics
from PySide6.QtWidgets import (
QFrame,
QHBoxLayout,
QLabel,
QPushButton,
QVBoxLayout,
)
from orisys_app_shared.acquisition.constants import FORCE_SAMPLE_RATE_HZ
from orisys_app_shared.force import MetricHistory
from orisys_app_shared.force.history import DEFAULT_MAX_FPS
@@ -27,6 +17,15 @@ from orisys_app_shared.force.source import StoreCurveSource
from orisys_app_shared.i18n import t
from orisys_app_shared.record.sample import plottable_axis_mask
from orisys_app_shared.theme import color
from PySide6.QtCore import QSize, Qt, Signal
from PySide6.QtGui import QColor, QFont, QFontDatabase, QFontMetrics
from PySide6.QtWidgets import (
QFrame,
QHBoxLayout,
QLabel,
QPushButton,
QVBoxLayout,
)
from orisys_studio.ui import icons
from orisys_studio.ui.icons import ICON_SIZE
@@ -130,11 +129,11 @@ def _mono_font(point_size: int = 9, *, bold: bool = False) -> QFont:
class _Sync:
"""Marks a block of range changes as programmatic (not a user gesture)."""
def __init__(self, panel: "ForcePlotsPanel") -> None:
def __init__(self, panel: ForcePlotsPanel) -> None:
self._panel = panel
self._previous = panel._syncing
def __enter__(self) -> "_Sync":
def __enter__(self) -> _Sync:
self._panel._syncing = True
return self
@@ -1054,7 +1053,7 @@ class ForcePlotsPanel(QFrame):
self._window = (x0, x1)
self.refresh_from_store()
def _guard(self) -> "_Sync":
def _guard(self) -> _Sync:
"""Context manager marking range changes as programmatic."""
return _Sync(self)
+1 -2
View File
@@ -14,11 +14,10 @@ from __future__ import annotations
from functools import lru_cache
from orisys_app_shared.theme import color
from PySide6.QtCore import QRectF, Qt
from PySide6.QtGui import QColor, QIcon, QPainter, QPen, QPixmap
from orisys_app_shared.theme import color
#: Names of the icons this module can paint.
NAMES = ("zoom_fit", "box_zoom", "latest", "settings", "reset_view")
@@ -13,9 +13,15 @@ acquisition, and no path that reports a 3D problem as a recording problem.
from __future__ import annotations
from collections.abc import Callable
from pathlib import Path
from typing import TYPE_CHECKING, Callable, Optional
from typing import TYPE_CHECKING
from orisys_app_shared.i18n import t
from orisys_app_shared.scene3d.contracts import (
Diagnostic,
ExpectedGeometry,
)
from PySide6.QtCore import QSize, Qt, Signal
from PySide6.QtWidgets import (
QFrame,
@@ -27,13 +33,6 @@ from PySide6.QtWidgets import (
QWidget,
)
from orisys_app_shared.i18n import t
from orisys_app_shared.scene3d.contracts import (
Diagnostic,
ExpectedGeometry,
SceneAssets,
diagnostic,
)
from orisys_studio.scene3d.asset_source import (
SceneAssetLoader,
SceneSource,
@@ -44,6 +43,7 @@ from orisys_studio.ui import icons
if TYPE_CHECKING: # the view imports GL bindings lazily; the type is enough here
from orisys_app_shared.acquisition.geometry import DeviceGeometry
from orisys_studio.scene3d.view import Scene3DView
#: Shown when the pane is on but this sensor has no 3D scene at all (box, mini).
@@ -81,17 +81,17 @@ class Mesh3dPanel(QFrame):
enabledChanged = Signal(bool)
def __init__(
self, parent: Optional[QWidget] = None, *, theme: str = "dark"
self, parent: QWidget | None = None, *, theme: str = "dark"
) -> None:
super().__init__(parent)
self.setObjectName("contentPanel")
self._theme = str(theme)
self._view: Optional["Scene3DView"] = None
self._loader: Optional[SceneAssetLoader] = None
self._source: Optional[SceneSource] = None
self._view: Scene3DView | None = None
self._loader: SceneAssetLoader | None = None
self._source: SceneSource | None = None
self._sensor_type = ""
self._expected: Optional[ExpectedGeometry] = None
self._expected_provider: "Optional[Callable[[], DeviceGeometry]]" = None
self._expected: ExpectedGeometry | None = None
self._expected_provider: Callable[[], DeviceGeometry] | None = None
self._source_kind = "live"
self._enabled = False
self._loaded = False
@@ -103,8 +103,8 @@ class Mesh3dPanel(QFrame):
self._keys = None
#: The package whose scene is in the view, so switching sensor away and back
#: does not reload it (and does not pretend to be loading it either).
self._loaded_path: Optional[Path] = None
self._reported: Optional[Diagnostic] = None
self._loaded_path: Path | None = None
self._reported: Diagnostic | None = None
self._pending_settings = None
self._message_kind = _UNAVAILABLE
self._message_args: dict[str, str] = {"reason": ""}
@@ -225,8 +225,8 @@ class Mesh3dPanel(QFrame):
self,
sensor_type: str,
*,
expected: Optional[ExpectedGeometry] = None,
expected_provider: "Optional[Callable[[], DeviceGeometry]]" = None,
expected: ExpectedGeometry | None = None,
expected_provider: Callable[[], DeviceGeometry] | None = None,
package_override: str | Path | None = None,
) -> None:
"""Tell the pane which sensor it is looking at. Cheap; no IO.
@@ -276,7 +276,7 @@ class Mesh3dPanel(QFrame):
return
self._show_message(_LOADING, name=self._source.path.name)
def attach_view(self, view: "Scene3DView") -> None:
def attach_view(self, view: Scene3DView) -> None:
"""Adopt a view: the real one (built lazily) or a double in a test.
Public because it is the seam tests use — poking ``_view`` from a test would
@@ -308,7 +308,7 @@ class Mesh3dPanel(QFrame):
if not view.available:
self._show_message(_UNAVAILABLE, reason=view.reason)
def ensure_view(self) -> Optional[QWidget]:
def ensure_view(self) -> QWidget | None:
"""Build the 3D view on first use, so a headless machine never imports GL."""
if self._view is not None or self._sensor_type != "finger":
return self._view
@@ -448,11 +448,11 @@ class Mesh3dPanel(QFrame):
# ------------------------------------------------------------------ inputs
@property
def view(self) -> Optional["Scene3DView"]:
def view(self) -> Scene3DView | None:
return self._view
@property
def last_diagnostic(self) -> Optional[Diagnostic]:
def last_diagnostic(self) -> Diagnostic | None:
return self._reported
@property
@@ -471,7 +471,7 @@ class Mesh3dPanel(QFrame):
"""Whether a 3D picture is possible here at all (GL and an asset)."""
return self._view is not None and bool(self._view.available)
def scene_path(self) -> Optional[Path]:
def scene_path(self) -> Path | None:
return None if self._source is None else self._source.path
def set_source_kind(self, kind: str) -> None:
@@ -10,6 +10,12 @@ reports as done is what the record will say (see ``force/filters.py``).
from __future__ import annotations
from orisys_app_shared.acquisition.constants import FORCE_SAMPLE_RATE_HZ
from orisys_app_shared.force.filters import (
FilterSettings,
available_presets,
)
from orisys_app_shared.i18n import t
from PySide6.QtWidgets import (
QCheckBox,
QComboBox,
@@ -25,14 +31,6 @@ from PySide6.QtWidgets import (
QVBoxLayout,
)
from orisys_app_shared.acquisition.constants import FORCE_SAMPLE_RATE_HZ
from orisys_app_shared.force.filters import (
SUGGESTED_LOWPASS_HZ,
FilterSettings,
available_presets,
)
from orisys_app_shared.i18n import t
DEFAULT_PLOT_WINDOW_SEC = 4.0
#: Lower bounds. FN is allowed below zero: a resting normal force has no reason
#: to sit exactly on the frame, and with the lower bound at 0 the idle curve is
@@ -14,10 +14,9 @@ timer without touching the writer thread.
from __future__ import annotations
from PySide6.QtWidgets import QLabel
from orisys_app_shared.i18n import t
from orisys_app_shared.theme import color
from PySide6.QtWidgets import QLabel
#: The recording channel is idle, never started in this session.
IDLE = "idle"
@@ -17,6 +17,7 @@ from __future__ import annotations
from datetime import datetime
from pathlib import Path
from orisys_app_shared.i18n import t
from PySide6.QtWidgets import (
QDialog,
QFrame,
@@ -26,8 +27,6 @@ from PySide6.QtWidgets import (
QVBoxLayout,
)
from orisys_app_shared.i18n import t
from orisys_studio.ui.fit_text import ShrinkableLabel
@@ -9,6 +9,8 @@ own labels and tooltips instead of a bare "配置" combo.
from __future__ import annotations
from orisys_app_shared.i18n import t
from orisys_app_shared.sensors import list_configs_for_type, list_sensor_types
from PySide6.QtCore import Qt, Signal
from PySide6.QtWidgets import (
QComboBox,
@@ -18,9 +20,6 @@ from PySide6.QtWidgets import (
QWidget,
)
from orisys_app_shared.i18n import t
from orisys_app_shared.sensors import list_configs_for_type, list_sensor_types
CONTROL_HEIGHT = 30
#: Both combos stay narrow: this row shares one line with the session state.
TYPE_WIDTH = 76
+2 -3
View File
@@ -19,6 +19,8 @@ scrolls sideways instead of squeezing the controls into an unreadable row.
from __future__ import annotations
from orisys_app_shared.i18n import t
from orisys_app_shared.theme import color
from PySide6.QtCore import Qt, Signal
from PySide6.QtWidgets import (
QComboBox,
@@ -33,9 +35,6 @@ from PySide6.QtWidgets import (
QWidget,
)
from orisys_app_shared.i18n import t
from orisys_app_shared.theme import color
from orisys_studio.ui.fit_text import ShrinkableLabel
from orisys_studio.ui.record_status import RecordStatusChip