[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 03/12] qapi/main: handle theoretical None-return from re.match
From: |
John Snow |
Subject: |
[PATCH v2 03/12] qapi/main: handle theoretical None-return from re.match() |
Date: |
Wed, 16 Dec 2020 20:59:18 -0500 |
Mypy cannot understand that this match can never be None, so help it
along.
Signed-off-by: John Snow <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 42517210b80..703e7ed1ed5 100644
--- a/scripts/qapi/main.py
+++ b/scripts/qapi/main.py
@@ -23,6 +23,8 @@
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 v2 00/12] qapi: static typing conversion, pt1.5, John Snow, 2020/12/16
- [PATCH v2 01/12] qapi/commands: assert arg_type is not None, John Snow, 2020/12/16
- [PATCH v2 02/12] qapi/events: fix visit_event typing, John Snow, 2020/12/16
- [PATCH v2 03/12] qapi/main: handle theoretical None-return from re.match(),
John Snow <=
- [PATCH v2 10/12] tests/qapi-schema: Add quotes to module name in test output, John Snow, 2020/12/16
- [PATCH v2 04/12] qapi/gen: assert that _start_if is not None in _wrap_ifcond, John Snow, 2020/12/16
- [PATCH v2 08/12] qapi/gen: write _genc/_genh access shims, John Snow, 2020/12/16
- [PATCH v2 12/12] qapi: enable strict-optional checks, John Snow, 2020/12/16
- [PATCH v2 07/12] qapi/schema: make QAPISourceInfo mandatory, John Snow, 2020/12/16
- [PATCH v2 05/12] qapi/gen: use './builtin' for the built-in module name, John Snow, 2020/12/16
- [PATCH v2 09/12] qapi/gen: move write method to QAPIGenC, make fname a str, John Snow, 2020/12/16
- [PATCH v2 06/12] qapi/source: Add builtin null-object sentinel, John Snow, 2020/12/16
- [PATCH v2 11/12] qapi/schema: Name the builtin module "" instead of None, John Snow, 2020/12/16