From a31af2a4c8d9d4e94c50df23fa0acc19ef44070e Mon Sep 17 00:00:00 2001 From: nayan Date: Mon, 21 Jul 2025 16:59:11 -0400 Subject: [PATCH] misc lint --- system/manager/process_config.py | 2 +- system/ui/sunnypilot/lib/list_view.py | 4 ++-- system/ui/sunnypilot/lib/option_control.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/system/manager/process_config.py b/system/manager/process_config.py index 6c1cc2314a..1768f74877 100644 --- a/system/manager/process_config.py +++ b/system/manager/process_config.py @@ -95,7 +95,7 @@ def and_(*fns): return lambda *args: operator.and_(*(fn(*args) for fn in fns)) def use_raylib(started: bool, params: Params, CP: car.CarParams) -> bool: - return params.get_bool("UseRaylib") + return bool(params.get_bool("UseRaylib")) def use_qt(started: bool, params: Params, CP: car.CarParams) -> bool: return not params.get_bool("UseRaylib") diff --git a/system/ui/sunnypilot/lib/list_view.py b/system/ui/sunnypilot/lib/list_view.py index 878f608da8..95059fc0d6 100644 --- a/system/ui/sunnypilot/lib/list_view.py +++ b/system/ui/sunnypilot/lib/list_view.py @@ -155,7 +155,7 @@ class OptionControlAction(ItemAction): self.option_control = OptionControl(min_value, max_value, initial_value, value_change_step, enabled, on_value_changed) - def _render(self, rect: rl.Rectangle) -> bool: + def _render(self, rect: rl.Rectangle) -> bool | int | None: self.option_control.set_enabled(self.enabled) return self.option_control.render(rect) @@ -168,4 +168,4 @@ def option_item(title: str, min_value: int, max_value: int, initial_value: int, action = OptionControlAction(min_value, max_value, initial_value, value_change_step, enabled, on_value_changed) return ListItemSP(title=title, description=description, - action_item=action, icon=icon) \ No newline at end of file + action_item=action, icon=icon) diff --git a/system/ui/sunnypilot/lib/option_control.py b/system/ui/sunnypilot/lib/option_control.py index bc47b2ab7b..8e370af17c 100644 --- a/system/ui/sunnypilot/lib/option_control.py +++ b/system/ui/sunnypilot/lib/option_control.py @@ -1,5 +1,5 @@ import pyray as rl -from typing import Callable, Union +from collections.abc import Callable from openpilot.system.ui.lib.widget import Widget from openpilot.system.ui.lib.application import gui_app, FontWeight from openpilot.system.ui.lib.text_measure import measure_text_cached @@ -20,7 +20,7 @@ OPTION_CONTROL_WIDTH = (BUTTON_WIDTH * 2) + LABEL_WIDTH + (BUTTON_SPACING * 2) + class OptionControl(Widget): def __init__(self, min_value: int, max_value: int, initial_value: int, - value_change_step: int = 1, enabled: bool = True, + value_change_step: int = 1, enabled: bool | Callable[[], bool]= True, on_value_changed: Callable[[int], None] | None = None): super().__init__() self.min_value = min_value @@ -175,7 +175,7 @@ class OptionControl(Widget): def _render_value_label(self, x: float, y: float): text = str(self.current_value) text_size = measure_text_cached(self._font, text, VALUE_FONT_SIZE) - + # Center the text in the label area with slight y-offset for visual balance text_x = x + (LABEL_WIDTH - text_size.x) / 2 text_y = y + (BUTTON_HEIGHT - text_size.y) / 2 - 2