Skip to content

Commit 41c42b8

Browse files
committed
Make it easier to debug version numbers.
1 parent 1210ee8 commit 41c42b8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/websockets/version.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def get_version(tag: str) -> str:
5555
else:
5656
description_re = r"[0-9.]+-([0-9]+)-(g[0-9a-f]{7,}(?:-dirty)?)"
5757
match = re.fullmatch(description_re, description)
58-
assert match is not None
58+
if match is None:
59+
raise ValueError(f"Unexpected git description: {description}")
5960
distance, remainder = match.groups()
6061
remainder = remainder.replace("-", ".") # required by PEP 440
6162
return f"{tag}.dev{distance}+{remainder}"
@@ -75,7 +76,8 @@ def get_commit(tag: str, version: str) -> str:
7576
# Extract commit from version, falling back to tag if not available.
7677
version_re = r"[0-9.]+\.dev[0-9]+\+g([0-9a-f]{7,}|unknown)(?:\.dirty)?"
7778
match = re.fullmatch(version_re, version)
78-
assert match is not None
79+
if match is None:
80+
raise ValueError(f"Unexpected version: {version}")
7981
(commit,) = match.groups()
8082
return tag if commit == "unknown" else commit
8183

0 commit comments

Comments
 (0)