Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 3 additions & 1 deletion stubs/JACK-Client/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
version = "0.5.*"
stubtest_apt_dependencies = ["libjack-dev"]

[tool.stubtest]
apt_dependencies = ["libjack-dev"]
3 changes: 2 additions & 1 deletion stubs/gdb/METADATA.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion stubs/pyaudio/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
version = "0.2.*"
stubtest_apt_dependencies = ["portaudio19-dev"]

[tool.stubtest]
apt_dependencies = ["portaudio19-dev"]
4 changes: 3 additions & 1 deletion stubs/pycurl/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
version = "7.44.*"
stubtest_apt_dependencies = ["libcurl4-openssl-dev"]

[tool.stubtest]
apt_dependencies = ["libcurl4-openssl-dev"]
4 changes: 3 additions & 1 deletion stubs/pynput/METADATA.toml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 7 additions & 9 deletions tests/check_consistent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,8 @@
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"}


Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/get_apt_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

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)
3 changes: 2 additions & 1 deletion tests/stubtest_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down