From 230cc3c37d02c8d5a20e574c32c5d46f9f104fd7 Mon Sep 17 00:00:00 2001 From: aychar <58487401+hrfarmer@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:45:54 -0500 Subject: [PATCH] move assert --- adafruit_rfm/rfm_common.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/adafruit_rfm/rfm_common.py b/adafruit_rfm/rfm_common.py index 43ce081..a7598e5 100644 --- a/adafruit_rfm/rfm_common.py +++ b/adafruit_rfm/rfm_common.py @@ -286,13 +286,6 @@ async def asyncio_send( # noqa: PLR0912 PLR0913 Returns: True if success or False if the send timed out. """ - # Disable pylint warning to not use length as a check for zero. - # This is a puzzling warning as the below code is clearly the most - # efficient and proper way to ensure a precondition that the provided - # buffer be within an expected range of bounds. Disable this check. - # pylint: disable=len-as-condition - assert 0 < len(data) <= self.max_packet_length - # pylint: enable=len-as-condition self.idle() # Stop receiving to clear FIFO and keep it clear. # Combine header and data to form payload if self.radiohead: @@ -318,6 +311,13 @@ async def asyncio_send( # noqa: PLR0912 PLR0913 payload = destination.to_bytes(1, "big") + data else: payload = data + # Disable pylint warning to not use length as a check for zero. + # This is a puzzling warning as the below code is clearly the most + # efficient and proper way to ensure a precondition that the provided + # buffer be within an expected range of bounds. Disable this check. + # pylint: disable=len-as-condition + assert 0 < len(payload) <= self.max_packet_length + # pylint: enable=len-as-condition self.fill_fifo(payload) # Turn on transmit mode to send out the packet. self.transmit()