Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64181e8

Browse files
authored
stubtest: use separate table in METADATA.toml (#8096)
1 parent 4240973 commit 64181e8

9 files changed

Lines changed: 30 additions & 19 deletions

File tree

CONTRIBUTING.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,13 @@ supported:
193193
* `no_longer_updated` (optional): This field is set to `true` before removing
194194
stubs for other reasons than the upstream library shipping with type
195195
information.
196-
* `stubtest` (default: `true`): Whether stubtest should be run against this
197-
package. Please avoid setting this to `false`, and add a comment if you have
196+
197+
In addition, we specify configuration for stubtest in the `tool.stubtest` table.
198+
This has the following keys:
199+
* `skip` (default: `false`): Whether stubtest should be run against this
200+
package. Please avoid setting this to `true`, and add a comment if you have
198201
to.
199-
* `stubtest_apt_dependencies` (default: `[]`): A list of Ubuntu APT packages
202+
* `apt_dependencies` (default: `[]`): A list of Ubuntu APT packages
200203
that need to be installed for stubtest to run successfully. These are
201204
usually packages needed to pip install the implementation distribution.
202205

stubs/JACK-Client/METADATA.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
version = "0.5.*"
2-
stubtest_apt_dependencies = ["libjack-dev"]
2+
3+
[tool.stubtest]
4+
apt_dependencies = ["libjack-dev"]

stubs/gdb/METADATA.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extra_description = """\
77
using `pip`.\
88
"""
99

10+
[tool.stubtest]
1011
# Since the "gdb" Python package is available only inside GDB, it is not
1112
# possible to install it through pip, so stub tests cannot install it.
12-
stubtest = false
13+
skip = true

stubs/pyaudio/METADATA.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
version = "0.2.*"
2-
stubtest_apt_dependencies = ["portaudio19-dev"]
2+
3+
[tool.stubtest]
4+
apt_dependencies = ["portaudio19-dev"]

stubs/pycurl/METADATA.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
version = "7.44.*"
2-
stubtest_apt_dependencies = ["libcurl4-openssl-dev"]
2+
3+
[tool.stubtest]
4+
apt_dependencies = ["libcurl4-openssl-dev"]

stubs/pynput/METADATA.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
version = "1.7.*"
2-
stubtest = false # A display server (e.g. X11) is required to import pynput
2+
3+
[tool.stubtest]
4+
skip = true # A display server (e.g. X11) is required to import pynput

tests/check_consistent.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,8 @@
1919
import tomli
2020

2121
consistent_files = [{"stdlib/@python2/builtins.pyi", "stdlib/@python2/__builtin__.pyi"}]
22-
metadata_keys = {
23-
"version",
24-
"requires",
25-
"extra_description",
26-
"obsolete_since",
27-
"no_longer_updated",
28-
"stubtest",
29-
"stubtest_apt_dependencies",
30-
}
22+
metadata_keys = {"version", "requires", "extra_description", "obsolete_since", "no_longer_updated", "tool"}
23+
tool_keys = {"stubtest": {"skip", "apt_dependencies"}}
3124
allowed_files = {"README.md"}
3225

3326

@@ -184,6 +177,11 @@ def check_metadata() -> None:
184177
for part in dep_version.split("."):
185178
assert part.isnumeric(), f"Bad version '{part}' in dependency {dep}"
186179

180+
assert set(data.get("tool", [])).issubset(tool_keys.keys()), f"Unrecognised tool for {distribution}"
181+
for tool, tk in tool_keys.items():
182+
for key in data.get("tool", {}).get(tool, {}):
183+
assert key in tk, f"Unrecognised {tool} key {key} for {distribution}"
184+
187185

188186
if __name__ == "__main__":
189187
check_stdlib()

tests/get_apt_packages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010

1111
for distribution in distributions:
1212
with open(f"stubs/{distribution}/METADATA.toml", "rb") as file:
13-
for apt_package in tomli.load(file).get("stubtest_apt_dependencies", []):
13+
for apt_package in tomli.load(file).get("tool", {}).get("stubtest", {}).get("apt_dependencies", []):
1414
print(apt_package)

tests/stubtest_third_party.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool:
2828

2929
print(f"{dist.name}... ", end="")
3030

31-
if not metadata.get("stubtest", True):
31+
stubtest_meta = metadata.get("tool", {}).get("stubtest", {})
32+
if stubtest_meta.get("skip", False):
3233
print(colored("skipping", "yellow"))
3334
return True
3435

0 commit comments

Comments
 (0)