]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qapi/parser: Mollify mypy
authorMarkus Armbruster <armbru@redhat.com>
Wed, 5 Nov 2025 15:22:19 +0000 (16:22 +0100)
committerRichard Henderson <richard.henderson@linaro.org>
Mon, 10 Nov 2025 10:57:18 +0000 (11:57 +0100)
re.match(r'^ *', ...) can't fail, but mypy doesn't know that and
complains:

    scripts/qapi/parser.py:444: error: Item "None" of "Match[str] | None" has no attribute "end"  [union-attr]

Work around by using must_match() instead.

Fixes: 8107ba47fd78 (qapi: Add documentation format validation)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20251105152219.311154-1-armbru@redhat.com>

scripts/qapi/parser.py

index 1bb1af7051f879f497d047748a2b5973128542bf..c3cf33904efb19538f5574dc47d8c578667e3b21 100644 (file)
@@ -441,7 +441,7 @@ class QAPISchemaParser:
             self._literal_mode = True
             self._literal_mode_indent = 0
         elif self._literal_mode and line:
-            indent = re.match(r'^ *', line).end()
+            indent = must_match(r'\s*', line).end()
             if self._literal_mode_indent == 0:
                 self._literal_mode_indent = indent
             elif indent < self._literal_mode_indent: