diff options
author | John Snow <jsnow@redhat.com> | 2021-02-01 14:37:35 -0500 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-02-08 14:15:58 +0100 |
commit | a253b3eb9a194a0b2e8b55095ce5f28c2d5cfa11 (patch) | |
tree | 33f13cc4620e052f818f4261254f4fa37f787860 /scripts/qapi/gen.py | |
parent | ad1218086efb469d292f5cdd3e8299e5d2e7d8d6 (diff) |
qapi/gen: inline _wrap_ifcond into end_if()
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>
Diffstat (limited to 'scripts/qapi/gen.py')
-rw-r--r-- | scripts/qapi/gen.py | 7 |
1 files 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 |