@@ -151,7 +151,7 @@ def parse_airos_packet(self, data: bytes, host_ip: str) -> dict[str, Any] | None
151151 log = f"Truncated MAC address TLV (Type 0x06). Expected { expected_length } , got { len (data ) - offset } bytes. Remaining: { data [offset :].hex ()} "
152152 _LOGGER .warning (log )
153153 log = f"Malformed packet: { log } "
154- raise AirOSEndpointError (log )
154+ raise AirOSEndpointError (log ) from None # noqa: TRY301
155155
156156 elif tlv_type in [
157157 0x02 ,
@@ -169,7 +169,7 @@ def parse_airos_packet(self, data: bytes, host_ip: str) -> dict[str, Any] | None
169169 log = f"Truncated TLV (Type { tlv_type :#x} ), no 2-byte length field. Remaining: { data [offset :].hex ()} "
170170 _LOGGER .warning (log )
171171 log = f"Malformed packet: { log } "
172- raise AirOSEndpointError (log )
172+ raise AirOSEndpointError (log ) from None # noqa: TRY301
173173
174174 tlv_length : int = struct .unpack_from (">H" , data , offset )[0 ]
175175 offset += 2
@@ -181,7 +181,7 @@ def parse_airos_packet(self, data: bytes, host_ip: str) -> dict[str, Any] | None
181181 f"Data from TLV start: { data [offset - 3 :].hex ()} "
182182 )
183183 _LOGGER .warning (log )
184- raise AirOSEndpointError (f"Malformed packet: { log } " )
184+ raise AirOSEndpointError (f"Malformed packet: { log } " ) from None # noqa: TRY301
185185
186186 tlv_value : bytes = data [offset : offset + tlv_length ]
187187
@@ -194,7 +194,9 @@ def parse_airos_packet(self, data: bytes, host_ip: str) -> dict[str, Any] | None
194194 else :
195195 log = f"Unexpected length for 0x02 TLV (MAC+IP). Expected 10, got { tlv_length } . Value: { tlv_value .hex ()} "
196196 _LOGGER .warning (log )
197- raise AirOSEndpointError (f"Malformed packet: { log } " )
197+ raise AirOSEndpointError ( # noqa: TRY301
198+ f"Malformed packet: { log } "
199+ ) from None
198200
199201 elif tlv_type == 0x03 :
200202 parsed_info ["firmware_version" ] = tlv_value .decode (
@@ -213,7 +215,9 @@ def parse_airos_packet(self, data: bytes, host_ip: str) -> dict[str, Any] | None
213215 else :
214216 log = f"Unexpected length for Uptime (Type 0x0A): { tlv_length } . Value: { tlv_value .hex ()} "
215217 _LOGGER .warning (log )
216- raise AirOSEndpointError (f"Malformed packet: { log } " )
218+ raise AirOSEndpointError ( # noqa: TRY301
219+ f"Malformed packet: { log } "
220+ ) from None
217221
218222 elif tlv_type == 0x0B :
219223 parsed_info ["hostname" ] = tlv_value .decode (
@@ -260,7 +264,7 @@ def parse_airos_packet(self, data: bytes, host_ip: str) -> dict[str, Any] | None
260264 log += f"Cannot determine length, stopping parsing. Remaining: { data [offset - 1 :].hex ()} "
261265 _LOGGER .warning (log )
262266 log = f"Malformed packet: { log } "
263- raise AirOSEndpointError (log )
267+ raise AirOSEndpointError (log ) from None # noqa: TRY301
264268
265269 except (struct .error , IndexError ) as err :
266270 log = f"Parsing error (struct/index) in AirOSDiscoveryProtocol: { err } at offset { offset } . Remaining data: { data [offset :].hex ()} "
0 commit comments