From 5870af2db9f785348612424c09fa103ca2d1347e Mon Sep 17 00:00:00 2001 From: Ivan Date: Thu, 23 Jul 2026 12:34:56 -0500 Subject: [PATCH] fix: type safety in LXST profiles compatibility functions by using type casting for callable native methods --- meshchatx.rsm | Bin 174471 -> 174471 bytes meshchatx/src/backend/lxst_profiles_compat.py | 10 +++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/meshchatx.rsm b/meshchatx.rsm index 012be9e817d6399b9dca286b26afb8b330640252..495bdf4aac497fda06387d03d92d887993b45d68 100644 GIT binary patch delta 193 zcmV;y06zbR(+Y>v3P6cp;W}&5S`0PgmJU@S#xA){f>BPUGXa-(;PiRf_JiPRiz|Nt z)8HVhO48^CCaeCQOF1+%zMU2QgGE>?Q4Enl7$DhVSWtDJE?r?=ZLYdxp!rPpVv3P8skh8~GUUQuHUY89~jGYcb^#=Tx{880mtw;O~#GXl0_E5WB) z?qp29Y*}eM2xpB+6Kc+@j~f4Krf{DlvH+1l7$B3X6=+RW3a|U#nYAezvE6$A9`|Qz z!68hhMc%FK$m+3p{*yp6GiEtqVKy={He_KlFg0X1GG#D1V`4NnGB`G4HDqBmWHmT6 vI50C}Wid5oG&W>1V`XAEIWc2oV`61yH(@iA@p2f0&XkAFlmWNSlmfXF?>0?r diff --git a/meshchatx/src/backend/lxst_profiles_compat.py b/meshchatx/src/backend/lxst_profiles_compat.py index e36545ec..c9aecd32 100644 --- a/meshchatx/src/backend/lxst_profiles_compat.py +++ b/meshchatx/src/backend/lxst_profiles_compat.py @@ -10,6 +10,9 @@ crashes when an older Profiles class is present. from __future__ import annotations +from collections.abc import Callable +from typing import Any, cast + # Match LXST 0.5+ Profiles constants when the installed package lacks them. MODE_FULL_DUPLEX = 0x01 MODE_HALF_DUPLEX = 0x02 @@ -58,7 +61,8 @@ def available_modes(profiles=None) -> list[int]: Profiles = profiles if profiles is not None else import_profiles() native = getattr(Profiles, "available_modes", None) if callable(native): - return list(native()) + modes = cast(Callable[[], Any], native)() + return [int(mode_id) for mode_id in modes] # Pre-duplex LXST: full duplex only. Half duplex needs switch_mode / squelch. return [mode_full_duplex(Profiles)] @@ -67,7 +71,7 @@ def mode_name(mode_id, profiles=None) -> str: Profiles = profiles if profiles is not None else import_profiles() native = getattr(Profiles, "mode_name", None) if callable(native): - return str(native(mode_id)) + return str(cast(Callable[[Any], Any], native)(mode_id)) return _MODE_NAMES.get(int(mode_id), "Default") @@ -75,5 +79,5 @@ def mode_abbreviation(mode_id, profiles=None) -> str: Profiles = profiles if profiles is not None else import_profiles() native = getattr(Profiles, "mode_abbrevation", None) if callable(native): - return str(native(mode_id)) + return str(cast(Callable[[Any], Any], native)(mode_id)) return _MODE_ABBREVS.get(int(mode_id), "DFLT")