stubtest: per project --ignore-missing-stub (#8122)

This commit is contained in:
Shantanu
2022-06-21 05:52:24 -07:00
committed by GitHub
parent f9e24680c3
commit 305f10b808
4 changed files with 9 additions and 5 deletions

View File

@@ -1 +1,4 @@
version = "3.0.*"
[tool.stubtest]
ignore_missing_stub = false

View File

@@ -4,6 +4,9 @@ from typing_extensions import SupportsIndex, final
VERSION: str
XXHASH_VERSION: str
VERSION_TUPLE: tuple[int, ...]
algorithms_available: set[str]
class _IntDigestHash(_Hash):
@property

View File

@@ -20,7 +20,7 @@ import tomli
consistent_files = [{"stdlib/@python2/builtins.pyi", "stdlib/@python2/__builtin__.pyi"}]
metadata_keys = {"version", "requires", "extra_description", "obsolete_since", "no_longer_updated", "tool"}
tool_keys = {"stubtest": {"skip", "apt_dependencies"}}
tool_keys = {"stubtest": {"skip", "apt_dependencies", "ignore_missing_stub"}}
allowed_files = {"README.md"}

View File

@@ -66,19 +66,17 @@ def run_stubtest(dist: Path, *, verbose: bool = False) -> bool:
print_command_failure("Failed to install", e)
return False
ignore_missing_stub = ["--ignore-missing-stub"] if stubtest_meta.get("ignore_missing_stub", True) else []
packages_to_check = [d.name for d in dist.iterdir() if d.is_dir() and d.name.isidentifier()]
modules_to_check = [d.stem for d in dist.iterdir() if d.is_file() and d.suffix == ".pyi"]
stubtest_cmd = [
python_exe,
"-m",
"mypy.stubtest",
# Use --ignore-missing-stub, because if someone makes a correct addition, they'll need to
# also make a allowlist change and if someone makes an incorrect addition, they'll run into
# false negatives.
"--ignore-missing-stub",
# Use --custom-typeshed-dir in case we make linked changes to stdlib or _typeshed
"--custom-typeshed-dir",
str(dist.parent.parent),
*ignore_missing_stub,
*packages_to_check,
*modules_to_check,
]