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 <jsnow@redhat.com> Message-Id: <20210201193747.2169670-4-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
3cc01c546b
commit
ad1218086e
@ -23,6 +23,8 @@ from .visit import gen_visit
|
|||||||
|
|
||||||
def invalid_prefix_char(prefix: str) -> Optional[str]:
|
def invalid_prefix_char(prefix: str) -> Optional[str]:
|
||||||
match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix)
|
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):
|
if match.end() != len(prefix):
|
||||||
return prefix[match.end()]
|
return prefix[match.end()]
|
||||||
return None
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user