[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 03/11] qapi/main: handle theoretical None-return from re.match()
From: |
Markus Armbruster |
Subject: |
[PATCH 03/11] qapi/main: handle theoretical None-return from re.match() |
Date: |
Fri, 18 Dec 2020 21:53:59 +0100 |
From: John Snow <jsnow@redhat.com>
Mypy cannot understand that this match can never be None, so help it
along.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20201217015927.197287-4-jsnow@redhat.com>
---
scripts/qapi/main.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py
index 42517210b8..703e7ed1ed 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
--
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, 2020/12/18
- [PATCH 03/11] qapi/main: handle theoretical None-return from re.match(),
Markus Armbruster <=
- [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