[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/16] qapi/gen: inline _wrap_ifcond into end_if()
From: |
Markus Armbruster |
Subject: |
[PULL 04/16] qapi/gen: inline _wrap_ifcond into end_if() |
Date: |
Mon, 8 Feb 2021 14:58:34 +0100 |
From: John Snow <jsnow@redhat.com>
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 | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
index b40f18eee3..3d81b90ab7 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -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
--
2.26.2
- [PULL 00/16] QAPI patches patches for 2021-02-08, Markus Armbruster, 2021/02/08
- [PULL 04/16] qapi/gen: inline _wrap_ifcond into end_if(),
Markus Armbruster <=
- [PULL 02/16] qapi/events: fix visit_event typing, Markus Armbruster, 2021/02/08
- [PULL 12/16] qapi/gen: Support switching to another module temporarily, Markus Armbruster, 2021/02/08
- [PULL 01/16] qapi/commands: assert arg_type is not None, Markus Armbruster, 2021/02/08
- [PULL 13/16] qapi/commands: Simplify command registry generation, Markus Armbruster, 2021/02/08
- [PULL 07/16] qapi: use explicitly internal module names, Markus Armbruster, 2021/02/08
- [PULL 03/16] qapi/main: handle theoretical None-return from re.match(), Markus Armbruster, 2021/02/08
- [PULL 06/16] qapi/gen: Replace ._begin_system_module(), Markus Armbruster, 2021/02/08
- [PULL 05/16] qapi: centralize is_[user|system|builtin]_module methods, Markus Armbruster, 2021/02/08
- [PULL 16/16] qapi: enable strict-optional checks, Markus Armbruster, 2021/02/08
- [PULL 11/16] qapi/gen: write _genc/_genh access shims, Markus Armbruster, 2021/02/08