From af8e2e93680cc8e89c040d95c1d78d0ba0d3015b Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Thu, 7 Oct 2021 15:15:08 +0200 Subject: [PATCH 1/2] Allow third-party versions to end in asterisk This is a first step towards #6095, where x.y and x.y.* are treated as equivalent. The next step is to update existing versions to use x.y.* where applicable and then treat x.y differently. --- CONTRIBUTING.md | 12 +++++++----- tests/check_consistent.py | 2 +- tests/stubtest_third_party.py | 5 ++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1025c3b7425..dd7ce4b3a47d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -95,15 +95,17 @@ The metadata file describes the stubs package using the [TOML file format](https://toml.io/en/). Currently, the following keys are supported: -* `version`: The latest version of the library that the stubs support. +* `version`: The versions of the library that the stubs support. For libraries that reflect API changes in the version number only - the parts indicating the API level should be specified. In the case - of [Semantic Versioning](https://semver.org/) that is the first two - components. When the stubs are updated to a newer version + the parts indicating the API level should be specified, with an + asterisk representing the API-independent part. In the case + of [Semantic Versioning](https://semver.org/), this version could look + like this: `2.7.*`. When the stubs are updated to a newer version of the library, the version of the stub should be bumped (note that previous versions are still available on PyPI). Some legacy stubs are marked with version `0.1`, indicating that their supported version is - unknown and needs to be updated. + unknown and needs to be updated. Other stubs don't use the asterisk + to denote the API-independent part. * `python2` (default: `false`): If set to `true`, the top-level stubs support both Python 2 and Python 3. * `requires` (optional): A list of other stub packages or packages with type diff --git a/tests/check_consistent.py b/tests/check_consistent.py index a29c71f40bdd..c6f9ff51425d 100755 --- a/tests/check_consistent.py +++ b/tests/check_consistent.py @@ -169,7 +169,7 @@ def check_metadata(): assert "version" in data, f"Missing version for {distribution}" version = data["version"] msg = f"Unsupported Python version {version}" - assert re.match(r"^\d+\.\d+(\.\d+)?$", version), msg + assert re.match(r"^\d+(\.\d+)*(\.\*)?$", version), msg for key in data: assert key in metadata_keys, f"Unexpected key {key} for {distribution}" assert isinstance(data.get("python2", False), bool), f"Invalid python2 value for {distribution}" diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 0cbe2728af77..8988c192daf4 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -48,8 +48,11 @@ def run_stubtest(dist: Path) -> None: python_exe = str(venv_dir / "bin" / "python") dist_version = metadata.get("version") - if dist_version is None or dist_version == "0.1": + assert isinstance(dist_version, str) + if dist_version == "0.1": dist_req = dist.name + elif dist_version.endswith(".*"): + dist_req = f"{dist.name}=={dist_version}" else: dist_req = f"{dist.name}=={dist_version}.*" From 5f371f33a439789ed35bdf8112db1933998d2801 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 8 Oct 2021 19:45:13 +0200 Subject: [PATCH 2/2] Update tests/stubtest_third_party.py Co-authored-by: Akuli --- tests/stubtest_third_party.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py index 8988c192daf4..fbd228a9b50a 100755 --- a/tests/stubtest_third_party.py +++ b/tests/stubtest_third_party.py @@ -47,7 +47,7 @@ def run_stubtest(dist: Path) -> None: pip_exe = str(venv_dir / "bin" / "pip") python_exe = str(venv_dir / "bin" / "python") - dist_version = metadata.get("version") + dist_version = metadata["version"] assert isinstance(dist_version, str) if dist_version == "0.1": dist_req = dist.name