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

@@ -193,10 +193,13 @@ supported:
* `no_longer_updated` (optional): This field is set to `true` before removing
stubs for other reasons than the upstream library shipping with type
information.
* `stubtest` (default: `true`): Whether stubtest should be run against this
package. Please avoid setting this to `false`, and add a comment if you have
In addition, we specify configuration for stubtest in the `tool.stubtest` table.
This has the following keys:
* `skip` (default: `false`): Whether stubtest should be run against this
package. Please avoid setting this to `true`, and add a comment if you have
to.
* `stubtest_apt_dependencies` (default: `[]`): A list of Ubuntu APT packages
* `apt_dependencies` (default: `[]`): A list of Ubuntu APT packages
that need to be installed for stubtest to run successfully. These are
usually packages needed to pip install the implementation distribution.

View File

@@ -1,2 +1,4 @@
version = "0.5.*"
stubtest_apt_dependencies = ["libjack-dev"]
[tool.stubtest]
apt_dependencies = ["libjack-dev"]

View File

@@ -7,6 +7,7 @@ extra_description = """\
using `pip`.\
"""
[tool.stubtest]
# Since the "gdb" Python package is available only inside GDB, it is not
# possible to install it through pip, so stub tests cannot install it.
stubtest = false
skip = true

View File

@@ -1,2 +1,4 @@
version = "0.2.*"
stubtest_apt_dependencies = ["portaudio19-dev"]
[tool.stubtest]
apt_dependencies = ["portaudio19-dev"]

View File

@@ -1,2 +1,4 @@
version = "7.44.*"
stubtest_apt_dependencies = ["libcurl4-openssl-dev"]
[tool.stubtest]
apt_dependencies = ["libcurl4-openssl-dev"]

View File

@@ -1,2 +1,4 @@
version = "1.7.*"
stubtest = false # A display server (e.g. X11) is required to import pynput
[tool.stubtest]
skip = true # A display server (e.g. X11) is required to import pynput

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