From: John Snow Date: Mon, 1 Feb 2021 19:37:34 +0000 (-0500) Subject: qapi/main: handle theoretical None-return from re.match() X-Git-Tag: v6.0.0-rc0~100^2~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad1218086efb469d292f5cdd3e8299e5d2e7d8d6;p=thirdparty%2Fqemu.git qapi/main: handle theoretical None-return from re.match() Mypy cannot understand that this match can never be None, so help it along. Signed-off-by: John Snow Message-Id: <20210201193747.2169670-4-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py index 42517210b80..703e7ed1ed5 100644 --- a/scripts/qapi/main.py +++ b/scripts/qapi/main.py @@ -23,6 +23,8 @@ from .visit import gen_visit def invalid_prefix_char(prefix: str) -> Optional[str]: match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix) + # match cannot be None, but mypy cannot infer that. + assert match is not None if match.end() != len(prefix): return prefix[match.end()] return None