mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 16:27:08 +08:00
Re-introduce the 'stubtest' key for third-party packages (#7351)
Some distributions can't be tested with stubtest for a variety of reasons or because of bugs in stubtest. This key: * let's us keep metadata about a distribution in one place, * prevents us from modifying the scripts because of issues with a specific distribution, and * will trigger tests if only the key is changed.
This commit is contained in:
@@ -18,7 +18,7 @@ import re
|
||||
import tomli
|
||||
|
||||
consistent_files = [{"stdlib/@python2/builtins.pyi", "stdlib/@python2/__builtin__.pyi"}]
|
||||
metadata_keys = {"version", "python2", "requires", "extra_description", "obsolete_since", "stubtest_apt_dependencies"}
|
||||
metadata_keys = {"version", "python2", "requires", "extra_description", "obsolete_since", "stubtest", "stubtest_apt_dependencies"}
|
||||
allowed_files = {"README.md"}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import tempfile
|
||||
import venv
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
from typing import NoReturn
|
||||
from typing import Any, NoReturn
|
||||
|
||||
import tomli
|
||||
|
||||
@@ -32,7 +32,7 @@ def run_stubtest(dist: Path) -> bool:
|
||||
with open(dist / "METADATA.toml") as f:
|
||||
metadata = dict(tomli.loads(f.read()))
|
||||
|
||||
if not has_py3_stubs(dist):
|
||||
if not run_stubtest_for(metadata, dist):
|
||||
print(f"Skipping stubtest for {dist.name}\n\n")
|
||||
return True
|
||||
|
||||
@@ -115,6 +115,10 @@ def run_stubtest(dist: Path) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def run_stubtest_for(metadata: dict[str, Any], dist: Path) -> bool:
|
||||
return has_py3_stubs(dist) and metadata.get("stubtest", True)
|
||||
|
||||
|
||||
# Keep this in sync with mypy_test.py
|
||||
def has_py3_stubs(dist: Path) -> bool:
|
||||
return len(glob(f"{dist}/*.pyi")) > 0 or len(glob(f"{dist}/[!@]*/__init__.pyi")) > 0
|
||||
@@ -137,9 +141,6 @@ def main() -> NoReturn:
|
||||
for i, dist in enumerate(dists):
|
||||
if i % args.num_shards != args.shard_index:
|
||||
continue
|
||||
if dist.name == "SQLAlchemy":
|
||||
# See https://github.com/python/typeshed/issues/7307
|
||||
continue
|
||||
if not run_stubtest(dist):
|
||||
result = 1
|
||||
sys.exit(result)
|
||||
|
||||
Reference in New Issue
Block a user