From 7c26da22bda786dce26d3a70fc18c14a7f4bd378 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 6 Jul 2024 23:42:15 +0300 Subject: [PATCH] Fix str2bool failure on stubsabot dry-run (#12287) --- scripts/stubsabot.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index 879db761e..7af9df619 100644 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -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}")