From 3bbda2d485a773c690148bb4056aa7e73a94ef3c Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 28 Nov 2026 15:44:03 -0600 Subject: [PATCH] ui: fix the type errors newer ty finds (#39505) --- .../selfdrive/ui/mici/layouts/settings/network/__init__.py | 2 +- openpilot/selfdrive/ui/translations/potools.py | 4 +++- openpilot/system/ui/text.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/openpilot/selfdrive/ui/mici/layouts/settings/network/__init__.py b/openpilot/selfdrive/ui/mici/layouts/settings/network/__init__.py index 79774f199a..6ac50c5a11 100644 --- a/openpilot/selfdrive/ui/mici/layouts/settings/network/__init__.py +++ b/openpilot/selfdrive/ui/mici/layouts/settings/network/__init__.py @@ -99,7 +99,7 @@ class WifiNetworkButton(BigButton): def _draw_content(self, btn_y: float): super()._draw_content(btn_y) # Render lock icon at lower right of wifi icon if secured - if self._draw_lock: + if self._draw_lock and self._txt_icon is not None: icon_x = self._rect.x + self._rect.width - 30 - self._txt_icon.width icon_y = btn_y + 30 lock_x = icon_x + self._txt_icon.width - self._lock_txt.width + 7 diff --git a/openpilot/selfdrive/ui/translations/potools.py b/openpilot/selfdrive/ui/translations/potools.py index 968f50d24b..dcb5ccf6d1 100644 --- a/openpilot/selfdrive/ui/translations/potools.py +++ b/openpilot/selfdrive/ui/translations/potools.py @@ -117,6 +117,7 @@ def parse_po(path: str | Path) -> tuple[POEntry | None, list[POEntry]]: m = re.match(r'msgstr\[(\d+)]\s+(.*)', stripped) if m: + assert cur is not None plural_idx = int(m.group(1)) cur.msgstr_plural[plural_idx] = _parse_quoted(m.group(2)) cur_field = 'msgstr_plural' @@ -130,6 +131,7 @@ def parse_po(path: str | Path) -> tuple[POEntry | None, list[POEntry]]: continue if stripped.startswith('"'): + assert cur is not None val = _parse_quoted(stripped) if cur_field == 'msgid': cur.msgid += val @@ -302,7 +304,7 @@ def init_po(pot_path: str | Path, po_path: str | Path, language: str) -> None: _, entries = parse_po(pot_path) plural_forms = PLURAL_FORMS.get(language, 'nplurals=2; plural=(n != 1);') - nplurals = int(re.search(r'nplurals=(\d+)', plural_forms).group(1)) + nplurals = int(re.findall(r'nplurals=(\d+)', plural_forms)[0]) for e in entries: if e.is_plural: e.msgstr_plural = dict.fromkeys(range(nplurals), '') diff --git a/openpilot/system/ui/text.py b/openpilot/system/ui/text.py index 10ddbcad20..141fc033ce 100755 --- a/openpilot/system/ui/text.py +++ b/openpilot/system/ui/text.py @@ -36,7 +36,7 @@ def wrap_text(text, font_size, max_width): if lines: lines.append("") continue - indent = re.match(r"^\s*", paragraph).group() + indent = paragraph[:len(paragraph) - len(paragraph.lstrip())] current_line = indent words = re.split(r"(\s+|-)", paragraph[len(indent):]) while len(words):