stubtest: use separate table in METADATA.toml (#8096)

This commit is contained in:
Shantanu
2022-06-19 00:43:24 -07:00
committed by GitHub
parent 42409735b2
commit 64181e8dad
9 changed files with 30 additions and 19 deletions

View File

@@ -19,15 +19,8 @@ import re
import tomli
consistent_files = [{"stdlib/@python2/builtins.pyi", "stdlib/@python2/__builtin__.pyi"}]
metadata_keys = {
"version",
"requires",
"extra_description",
"obsolete_since",
"no_longer_updated",
"stubtest",
"stubtest_apt_dependencies",
}
metadata_keys = {"version", "requires", "extra_description", "obsolete_since", "no_longer_updated", "tool"}
tool_keys = {"stubtest": {"skip", "apt_dependencies"}}
allowed_files = {"README.md"}
@@ -184,6 +177,11 @@ def check_metadata() -> None:
for part in dep_version.split("."):
assert part.isnumeric(), f"Bad version '{part}' in dependency {dep}"
assert set(data.get("tool", [])).issubset(tool_keys.keys()), f"Unrecognised tool for {distribution}"
for tool, tk in tool_keys.items():
for key in data.get("tool", {}).get(tool, {}):
assert key in tk, f"Unrecognised {tool} key {key} for {distribution}"
if __name__ == "__main__":
check_stdlib()

View File

@@ -10,5 +10,5 @@ if not distributions:
for distribution in distributions:
with open(f"stubs/{distribution}/METADATA.toml", "rb") as file:
for apt_package in tomli.load(file).get("stubtest_apt_dependencies", []):
for apt_package in tomli.load(file).get("tool", {}).get("stubtest", {}).get("apt_dependencies", []):
print(apt_package)

View File

@@ -28,7 +28,8 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool:
print(f"{dist.name}... ", end="")
if not metadata.get("stubtest", True):
stubtest_meta = metadata.get("tool", {}).get("stubtest", {})
if stubtest_meta.get("skip", False):
print(colored("skipping", "yellow"))
return True