misc lint

This commit is contained in:
nayan
2025-07-21 16:59:11 -04:00
parent 09e392afad
commit a31af2a4c8
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -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")
+2 -2
View File
@@ -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)
action_item=action, icon=icon)
+3 -3
View File
@@ -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