From e601c09cd26f2dead0da65885c0fab3e08950475 Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Tue, 28 Jul 2026 11:36:09 +0200 Subject: [PATCH] mavutil: add type annotations to mavfile_state and param_state Declares real attribute types on the per-sysid/param state helper classes so mavfile's proxying properties (target_system, messages, flightmode, etc.) can be typed accurately in a follow-up step instead of falling back to Any. Co-Authored-By: Claude Sonnet 5 --- mavutil.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mavutil.py b/mavutil.py index 693308bdc..2f6a04a6f 100644 --- a/mavutil.py +++ b/mavutil.py @@ -145,14 +145,14 @@ def set_dialect(dialect: str, with_type_annotations: bool | None = None) -> None class mavfile_state(object): '''state for a particular system id''' - def __init__(self): - self.messages = { 'MAV' : self } - self.flightmode = "UNKNOWN" - self.vehicle_type = "UNKNOWN" - self.mav_type = mavlink.MAV_TYPE_FIXED_WING - self.mav_autopilot = mavlink.MAV_AUTOPILOT_GENERIC - self.base_mode = 0 - self.armed = False # canonical arm state for the vehicle as a whole + def __init__(self) -> None: + self.messages: dict[str, Any] = { 'MAV' : self } + self.flightmode: str = "UNKNOWN" + self.vehicle_type: str = "UNKNOWN" + self.mav_type: int = mavlink.MAV_TYPE_FIXED_WING + self.mav_autopilot: int = mavlink.MAV_AUTOPILOT_GENERIC + self.base_mode: int = 0 + self.armed: bool = False # canonical arm state for the vehicle as a whole if float(mavlink.WIRE_PROTOCOL_VERSION) >= 1: try: @@ -174,8 +174,8 @@ def __init__(self): class param_state(object): '''state for a particular system id/component id pair''' - def __init__(self): - self.params = {} + def __init__(self) -> None: + self.params: dict[str, float] = {} class mavfile(object): '''a generic mavlink port'''