diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c2d23811e07..77afb7029c00 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -176,6 +176,9 @@ supported: [removing obsolete third-party libraries](#third-party-library-removal-policy). It contains the first version of the corresponding library that ships its own `py.typed` file. +* `stubtest` (default: `true`): Whether stubtest should be run against this + package. Please avoid setting this to `false`, and add a comment if you have + to. * `stubtest_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. diff --git a/stubs/SQLAlchemy/METADATA.toml b/stubs/SQLAlchemy/METADATA.toml index 5a3c17ff016a..72be0540cffd 100644 --- a/stubs/SQLAlchemy/METADATA.toml +++ b/stubs/SQLAlchemy/METADATA.toml @@ -3,3 +3,4 @@ extra_description = """\ The `sqlalchemy-stubs` package is an alternative to this package and also \ includes a mypy plugin for more precise types.\ """ +stubtest = false # https://github.com/python/typeshed/issues/7307 diff --git a/tests/check_consistent.py b/tests/check_consistent.py index cf1d4ac21f44..02a04dc455d0 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -18,7 +18,7 @@ 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"} diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 017558e44dde..3c858a056ae3 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -11,7 +11,7 @@ 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)