From 363dd8440b68cd1ada1a1702bfb12b8127146e1f Mon Sep 17 00:00:00 2001 From: "Olivier Wilkinson (reivilibre)" Date: Wed, 28 Dec 2022 14:46:16 +0000 Subject: [PATCH] Support the other style of lockfile --- scripts-dev/check_locked_deps_have_sdists.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts-dev/check_locked_deps_have_sdists.py b/scripts-dev/check_locked_deps_have_sdists.py index 703d2bbbc8e9..ecb3601c2146 100755 --- a/scripts-dev/check_locked_deps_have_sdists.py +++ b/scripts-dev/check_locked_deps_have_sdists.py @@ -24,9 +24,16 @@ def main() -> None: with open(lockfile_path, "rb") as lockfile: lockfile_content = tomli.load(lockfile) - packages_to_assets: Dict[str, List[Dict[str, str]]] = lockfile_content["metadata"][ - "files" - ] + packages_to_assets: Dict[str, List[Dict[str, str]]] + # There seem to be two different formats for storing the list of files per package. + if lockfile_content.get("metadata", {}).get("files") is not None: + # either [metadata.files] + packages_to_assets = lockfile_content["metadata"]["files"] + else: + # or a `files` inline table in each [[package]] + packages_to_assets = { + package["name"]: package["files"] for package in lockfile_content["package"] + } success = True @@ -46,6 +53,11 @@ def main() -> None: ) sys.exit(1) + print( + f"Poetry lockfile OK. {len(packages_to_assets)} locked packages checked.", + file=sys.stderr, + ) + if __name__ == "__main__": main()