From 07b5e33e09e6ea16e42bd73ed10e0f3da9b0e5c4 Mon Sep 17 00:00:00 2001 From: ibondarenko1 Date: Sun, 26 Apr 2026 18:49:55 -0700 Subject: [PATCH] =?UTF-8?q?avdtp:=20address=20review=20nits=20=E2=80=94=20?= =?UTF-8?q?use=20truthy=20checks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per @zxzxwu review on #918: - bumble/avdtp.py: replace `if len(pdu) < 1:` with `if not pdu:` - tests/avdtp_test.py: replace `assert completed == []` with `assert not completed` Both are idiomatic Python truthy checks; behavior identical. --- bumble/avdtp.py | 2 +- tests/avdtp_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bumble/avdtp.py b/bumble/avdtp.py index becafbd..9e9b836 100644 --- a/bumble/avdtp.py +++ b/bumble/avdtp.py @@ -314,7 +314,7 @@ class MessageAssembler: # Drop empty PDUs sent by remote — accessing pdu[0] below would # raise IndexError, propagating up to the L2CAP read loop and # tearing down the channel. Same class as #912 (ATT empty PDU). - if len(pdu) < 1: + if not pdu: logger.warning('AVDTP message assembler: empty PDU dropped') return diff --git a/tests/avdtp_test.py b/tests/avdtp_test.py index d5df431..242bdae 100644 --- a/tests/avdtp_test.py +++ b/tests/avdtp_test.py @@ -142,7 +142,7 @@ def test_message_assembler_truncated_pdu(pdu: bytes): assembler = avdtp.MessageAssembler(callback) # Must not raise; nothing should be delivered to callback either. assembler.on_pdu(pdu) - assert completed == [] + assert not completed # -----------------------------------------------------------------------------