فهرست منبع

Check value properly instead of using assert

Tulir Asokan 3 سال پیش
والد
کامیت
f199bcccf6
1فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  1. 4 4
      mauigpapi/mqtt/conn.py

+ 4 - 4
mauigpapi/mqtt/conn.py

@@ -235,12 +235,12 @@ class AndroidMQTT:
     def _parse_direct_thread_path(self, path: str) -> dict:
         try:
             blank, direct_v2, threads, thread_id, *rest = path.split("/")
-            assert blank == ""
-            assert direct_v2 == "direct_v2"
-            assert threads == "threads"
-        except (AssertionError, ValueError, IndexError) as e:
+        except (ValueError, IndexError) as e:
             self.log.debug(f"Got {e!r} while parsing path {path}")
             raise
+        if (blank, direct_v2, threads) != ("", "direct_v2", "threads"):
+            self.log.debug(f"Got unexpected first parts in direct thread path {path}")
+            raise ValueError("unexpected first three parts in _parse_direct_thread_path")
         additional = {
             "thread_id": thread_id
         }