Fix str2bool failure on stubsabot dry-run (#12287)

This commit is contained in:
sobolevn
2024-07-06 23:42:15 +03:00
committed by GitHub
parent 99c1b7102a
commit 7c26da22bd

View File

@@ -230,11 +230,16 @@ async def release_contains_py_typed(release_to_download: PypiReleaseDownload, *,
with zipfile.ZipFile(body) as zf:
return all_py_files_in_source_are_in_py_typed_dirs(zf)
elif packagetype == "sdist":
assert release_to_download.filename.endswith(
".tar.gz"
), f"Package file {release_to_download.filename!r} does not end with '.tar.gz'"
with tarfile.open(fileobj=body, mode="r:gz") as zf:
return all_py_files_in_source_are_in_py_typed_dirs(zf)
# sdist defaults to `.tar.gz` on Lunix and to `.zip` on Windows:
# https://docs.python.org/3.11/distutils/sourcedist.html
if release_to_download.filename.endswith(".tar.gz"):
with tarfile.open(fileobj=body, mode="r:gz") as zf:
return all_py_files_in_source_are_in_py_typed_dirs(zf)
elif release_to_download.filename.endswith(".zip"):
with zipfile.ZipFile(body) as zf:
return all_py_files_in_source_are_in_py_typed_dirs(zf)
else:
raise AssertionError(f"Package file {release_to_download.filename!r} does not end with '.tar.gz' or '.zip'")
else:
raise AssertionError(f"Unknown package type for {release_to_download.distribution}: {packagetype!r}")