@@ -54,21 +54,21 @@ def build(build_dir: str) -> str:
5454 build_cmd , stdout = subprocess .DEVNULL , check = True , env = env
5555 )
5656
57- build_version = None
5857 for filename in os .listdir (build_dir ):
5958 prefix , postfix = f"{ PYPI_PROJECT } -" , ".tar.gz"
6059 if filename .startswith (prefix ) and filename .endswith (postfix ):
61- build_version = filename [len (prefix ) : - len (postfix )]
60+ return filename [len (prefix ) : - len (postfix )]
6261
63- assert build_version
64- return build_version
62+ raise RuntimeError ("Build version not found" )
6563
6664
6765def get_git_version () -> str :
6866 """Return version string from git describe"""
6967 cmd = ["git" , "describe" ]
7068 process = subprocess .run (cmd , text = True , capture_output = True , check = True )
71- assert process .stdout .startswith ("v" ) and process .stdout .endswith ("\n " )
69+ if not process .stdout .startswith ("v" ) or not process .stdout .endswith ("\n " ):
70+ raise RuntimeError (f"Unexpected git version { process .stdout } " )
71+
7272 return process .stdout [1 :- 1 ]
7373
7474
@@ -93,7 +93,7 @@ def get_pypi_pip_version() -> str:
9393 prefix , postfix = f"{ PYPI_PROJECT } -" , ".tar.gz"
9494 if filename .startswith (prefix ) and filename .endswith (postfix ):
9595 return filename [len (prefix ) : - len (postfix )]
96- assert False
96+ raise RuntimeError ( "PyPI version not found" )
9797
9898
9999def verify_github_release (version : str , compare_dir : str ) -> bool :
@@ -164,7 +164,9 @@ def sign_release_artifacts(
164164 subprocess .run (
165165 cmd + ["--output" , signature_path , artifact_path ], check = True
166166 )
167- assert os .path .exists (signature_path )
167+
168+ if not os .path .exists (signature_path ):
169+ raise RuntimeError ("Signing failed, signature not found" )
168170
169171
170172def finished (s : str ) -> None :
@@ -209,7 +211,10 @@ def main() -> int: # noqa: D103
209211 finished (f"Built release { build_version } " )
210212
211213 git_version = get_git_version ()
212- assert git_version .startswith (build_version )
214+ if not git_version .startswith (build_version ):
215+ raise RuntimeError (
216+ f"Git version is { git_version } , expected { build_version } "
217+ )
213218 if git_version != build_version :
214219 finished (f"WARNING: Git describes version as { git_version } " )
215220
0 commit comments