qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 10/25] qapi/schema.py: Add assertion to ifcond property


From: John Snow
Subject: [PATCH 10/25] qapi/schema.py: Add assertion to ifcond property
Date: Tue, 22 Sep 2020 18:44:46 -0400

ifcond's initialization allows a fairly confusing type, but we want to
assert that after the QAPISchema is built, this always returns a
List[str]. Add an assertion to allow us to say that.

(Note: Technically, I only assert that it's a list -- but type hints
that will be added later will make it clear that the only possible list
we could have here is a list[str], and this assertion is sufficient to
prove the point to mypy.)

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/schema.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index b35f741c6f..62b1a7e890 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -88,7 +88,7 @@ def set_module(self, schema):
 
     @property
     def ifcond(self):
-        assert self._checked
+        assert self._checked and isinstance(self._ifcond, list)
         return self._ifcond
 
     def is_implicit(self):
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]