diff mbox series

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

Message ID 20200922224501.4087749-11-jsnow@redhat.com
State New
Headers show
Series qapi: static typing conversion, pt6 | expand

Commit Message

John Snow Sept. 22, 2020, 10:44 p.m. UTC
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 mbox series

Patch

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):