subprocess: use more mypy-friendly syntax

This commit is contained in:
James R. Barlow
2020-12-11 14:14:21 -08:00
parent d2908640c6
commit 5172dbde8d
+4 -3
View File
@@ -159,13 +159,14 @@ def get_version(
raise MissingDependencyError(
f"Could not find program '{program}' on the PATH"
) from e
try:
version = re.match(regex, output.strip()).group(1)
except AttributeError as e:
match = re.match(regex, output.strip())
if not match:
raise MissingDependencyError(
f"The program '{program}' did not report its version. "
f"Message was:\n{output}"
)
version = match.group(1)
return version