[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/11] qapi/gen: assert that _start_if is not None in _wrap_ifcon
From: |
Markus Armbruster |
Subject: |
[PATCH 04/11] qapi/gen: assert that _start_if is not None in _wrap_ifcond |
Date: |
Fri, 18 Dec 2020 21:54:00 +0100 |
From: John Snow <jsnow@redhat.com>
We already assert this in end_if, but that's opaque to mypy. Do it in
_wrap_ifcond instead. Same effect at runtime, but mypy can now infer
the type in _wrap_ifcond's body.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20201217015927.197287-5-jsnow@redhat.com>
---
scripts/qapi/gen.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
index b40f18eee3..a6dc991b1d 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -130,11 +130,11 @@ 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
self._body = _wrap_ifcond(self._start_if[0],
self._start_if[1], self._body)
self._preamble = _wrap_ifcond(self._start_if[0],
--
2.26.2
- [PATCH 00/11] Drop support for QAPIGen without a file name, Markus Armbruster, 2020/12/18
- [PATCH 01/11] qapi/commands: assert arg_type is not None, Markus Armbruster, 2020/12/18
- [PATCH 04/11] qapi/gen: assert that _start_if is not None in _wrap_ifcond,
Markus Armbruster <=
- [PATCH 03/11] qapi/main: handle theoretical None-return from re.match(), Markus Armbruster, 2020/12/18
- [PATCH 07/11] qapi/gen: Replace ._begin_system_module(), Markus Armbruster, 2020/12/18
- [PATCH 06/11] qapi/gen: write _genc/_genh access shims, Markus Armbruster, 2020/12/18
- [PATCH 11/11] qapi/gen: Drop support for QAPIGen without a file name, Markus Armbruster, 2020/12/18
- [PATCH 02/11] qapi/events: fix visit_event typing, Markus Armbruster, 2020/12/18
- [PATCH 08/11] qapi/gen: Expose a single module name space, Markus Armbruster, 2020/12/18
- [PATCH 09/11] qapi/gen: Support for switching to another module temporarily, Markus Armbruster, 2020/12/18
- [PATCH 05/11] qapi/gen: use './builtin' for the built-in module name, Markus Armbruster, 2020/12/18
- [PATCH 10/11] qapi/commands: Simplify command registry generation, Markus Armbruster, 2020/12/18