From 4a1fb82a3501faea42515eb52d27c0ff43346dde Mon Sep 17 00:00:00 2001 From: nayan Date: Tue, 22 Jul 2025 11:58:15 -0400 Subject: [PATCH] lint.. LINT.!! LIIINNNTTTT...!!!! --- .../ui/sunnypilot/layouts/settings/device.py | 1 - system/ui/sunnypilot/lib/list_view.py | 2 +- system/ui/sunnypilot/lib/option_control.py | 15 +++++++++------ system/ui/sunnypilot/lib/styles.py | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/selfdrive/ui/sunnypilot/layouts/settings/device.py b/selfdrive/ui/sunnypilot/layouts/settings/device.py index 1ed94d8b99..0c2b0bfe78 100644 --- a/selfdrive/ui/sunnypilot/layouts/settings/device.py +++ b/selfdrive/ui/sunnypilot/layouts/settings/device.py @@ -32,7 +32,6 @@ DESCRIPTIONS = { class DeviceLayoutSP(DeviceLayout): def __init__(self): DeviceLayout.__init__(self) - items = self._initialize_items() def _hide_item(self, item): return (item.title in {"Driver Camera", "Regulatory", "Review Training Guide", "Change Language"} diff --git a/system/ui/sunnypilot/lib/list_view.py b/system/ui/sunnypilot/lib/list_view.py index 2fef761f48..f660889f28 100644 --- a/system/ui/sunnypilot/lib/list_view.py +++ b/system/ui/sunnypilot/lib/list_view.py @@ -177,7 +177,7 @@ def option_item_sp(title: str, description: str | Callable[[], str] | None, para min_value: int, max_value: int, value_change_step: int = 1, on_value_changed: Callable[[int], None] | None = None, enabled: bool | Callable[[], bool] = True, - icon: str = "", value_map: dict[str, str] | None = None, + icon: str = "", value_map: dict[str, tuple[str, str]] | None = None, use_float_scaling: bool = False) -> ListItem: action = OptionControlActionSP( param, min_value, max_value, value_change_step, diff --git a/system/ui/sunnypilot/lib/option_control.py b/system/ui/sunnypilot/lib/option_control.py index 553f2f06ea..db473f315c 100644 --- a/system/ui/sunnypilot/lib/option_control.py +++ b/system/ui/sunnypilot/lib/option_control.py @@ -1,6 +1,6 @@ import pyray as rl from collections.abc import Callable -from typing import Dict, Optional, Union, Tuple +from typing import Optional, Union from openpilot.common.params import Params from openpilot.system.ui.lib.widget import Widget from openpilot.system.ui.lib.application import gui_app, FontWeight @@ -29,9 +29,9 @@ class OptionControlSP(Widget): """ def __init__(self, param: str, min_value: int, max_value: int, - value_change_step: int = 1, enabled: Union[bool, Callable[[], bool]] = True, - on_value_changed: Optional[Callable[[int], None]] = None, - value_map: Optional[Dict[str, Tuple[str, str]]] = None, + value_change_step: int = 1, enabled: bool | Callable[[], bool] = True, + on_value_changed: Callable[[int], None] | None = None, + value_map: dict[str, tuple[str, str]] | None = None, use_float_scaling: bool = False): super().__init__() @@ -69,7 +69,7 @@ class OptionControlSP(Widget): self.text_pressed = rl.Color(255, 255, 255, 255) # Pressed text self.text_disabled = rl.Color(92, 92, 92, 255) # Disabled text - def set_enabled(self, enabled: Union[bool, Callable[[], bool]]): + def set_enabled(self, enabled: bool | Callable[[], bool]): """Set whether the control is enabled""" self._enabled = enabled @@ -81,7 +81,10 @@ class OptionControlSP(Widget): """Set the control to a specific value""" if self.min_value <= value <= self.max_value: self.current_value = value - self.params.put(self.param_key, str(value)) + if self.value_map: + self.params.put(self.param_key, str(self.value_map[str(value)][0])) + else: + self.params.put(self.param_key, str(value)) if self.on_value_changed: self.on_value_changed(value) diff --git a/system/ui/sunnypilot/lib/styles.py b/system/ui/sunnypilot/lib/styles.py index d524c5b8b8..c0455842d9 100644 --- a/system/ui/sunnypilot/lib/styles.py +++ b/system/ui/sunnypilot/lib/styles.py @@ -19,7 +19,7 @@ class Default: ITEM_DESC_V_OFFSET = 150 TOGGLE_HEIGHT = 100 - TOGGLE_WIDTH = TOGGLE_HEIGHT * 1.75 + TOGGLE_WIDTH = int(TOGGLE_HEIGHT * 1.75) TOGGLE_BG_HEIGHT = TOGGLE_HEIGHT - 20 BUTTON_WIDTH = 250