Skip to content

Commit 46fc031

Browse files
srittauAkuli
andauthored
Allow third-party versions to end in asterisk (#6129)
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. Co-authored-by: Akuli <[email protected]>
1 parent 0142ea8 commit 46fc031

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@ The metadata file describes the stubs package using the
9595
[TOML file format](https://toml.io/en/). Currently, the following keys are
9696
supported:
9797

98-
* `version`: The latest version of the library that the stubs support.
98+
* `version`: The versions of the library that the stubs support.
9999
For libraries that reflect API changes in the version number only
100-
the parts indicating the API level should be specified. In the case
101-
of [Semantic Versioning](https://semver.org/) that is the first two
102-
components. When the stubs are updated to a newer version
100+
the parts indicating the API level should be specified, with an
101+
asterisk representing the API-independent part. In the case
102+
of [Semantic Versioning](https://semver.org/), this version could look
103+
like this: `2.7.*`. When the stubs are updated to a newer version
103104
of the library, the version of the stub should be bumped (note that
104105
previous versions are still available on PyPI). Some legacy stubs are
105106
marked with version `0.1`, indicating that their supported version is
106-
unknown and needs to be updated.
107+
unknown and needs to be updated. Other stubs don't use the asterisk
108+
to denote the API-independent part.
107109
* `python2` (default: `false`): If set to `true`, the top-level stubs
108110
support both Python 2 and Python 3.
109111
* `requires` (optional): A list of other stub packages or packages with type

tests/check_consistent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def check_metadata():
169169
assert "version" in data, f"Missing version for {distribution}"
170170
version = data["version"]
171171
msg = f"Unsupported Python version {version}"
172-
assert re.match(r"^\d+\.\d+(\.\d+)?$", version), msg
172+
assert re.match(r"^\d+(\.\d+)*(\.\*)?$", version), msg
173173
for key in data:
174174
assert key in metadata_keys, f"Unexpected key {key} for {distribution}"
175175
assert isinstance(data.get("python2", False), bool), f"Invalid python2 value for {distribution}"

tests/stubtest_third_party.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ def run_stubtest(dist: Path) -> None:
4747
pip_exe = str(venv_dir / "bin" / "pip")
4848
python_exe = str(venv_dir / "bin" / "python")
4949

50-
dist_version = metadata.get("version")
51-
if dist_version is None or dist_version == "0.1":
50+
dist_version = metadata["version"]
51+
assert isinstance(dist_version, str)
52+
if dist_version == "0.1":
5253
dist_req = dist.name
54+
elif dist_version.endswith(".*"):
55+
dist_req = f"{dist.name}=={dist_version}"
5356
else:
5457
dist_req = f"{dist.name}=={dist_version}.*"
5558

0 commit comments

Comments
 (0)