qapi/gen: inline _wrap_ifcond into end_if()
authorJohn Snow <jsnow@redhat.com>
Mon, 1 Feb 2021 19:37:35 +0000 (14:37 -0500)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 8 Feb 2021 13:15:58 +0000 (14:15 +0100)
We assert _start_if is not None in end_if, but that's opaque to mypy.
By inlining _wrap_ifcond, that constraint becomes provable to mypy.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210201193747.2169670-5-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/gen.py

index b40f18eee3cdc7f199a67e91ca4718e3bec93579..3d81b90ab718b7f5de8f2b4d59ef68cbbc9c7eef 100644 (file)
@@ -130,15 +130,12 @@ class QAPIGenCCode(QAPIGen):
         self._start_if = (ifcond, self._body, self._preamble)
 
     def end_if(self) -> None:
-        assert self._start_if
-        self._wrap_ifcond()
-        self._start_if = None
-
-    def _wrap_ifcond(self) -> None:
+        assert self._start_if is not None
         self._body = _wrap_ifcond(self._start_if[0],
                                   self._start_if[1], self._body)
         self._preamble = _wrap_ifcond(self._start_if[0],
                                       self._start_if[2], self._preamble)
+        self._start_if = None
 
     def get_content(self) -> str:
         assert self._start_if is None