diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f8263498c4da..dc64d4953085 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -176,10 +176,10 @@ supported: This defaults to `types-` and should only be set in special cases. * `upstream-repository` (recommended): The URL of the upstream repository. -* `obsolete-since` (optional): This field is part of our process for +* `obsolete-since` (optional): This table is part of our process for [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. + its own `py.typed` file, and the date when that version was released. * `no-longer-updated` (optional): This field is set to `true` before removing stubs for other reasons than the upstream library shipping with type information. diff --git a/lib/ts_utils/metadata.py b/lib/ts_utils/metadata.py index 4243129b64a7..b18fe5374eb2 100644 --- a/lib/ts_utils/metadata.py +++ b/lib/ts_utils/metadata.py @@ -24,7 +24,6 @@ import tomlkit from packaging.requirements import Requirement from packaging.specifiers import Specifier -from tomlkit.items import String from .paths import PYPROJECT_PATH, STUBS_PATH, distribution_path @@ -299,12 +298,15 @@ def read_metadata(distribution: str) -> StubMetadata: assert num_url_path_parts == 2, bad_github_url_msg obsolete_since = data.get("obsolete-since") - assert isinstance(obsolete_since, (String, type(None))) - if obsolete_since: - comment = obsolete_since.trivia.comment - since_date_string = comment.removeprefix("# Released on ") - since_date = datetime.date.fromisoformat(since_date_string) - obsolete = ObsoleteMetadata(since_version=obsolete_since, since_date=since_date) + assert isinstance(obsolete_since, (dict, type(None))) + if obsolete_since is not None: + obsolete_table: dict[str, object] = obsolete_since + obsolete_since_version = obsolete_table.get("version") + obsolete_since_date = obsolete_table.get("date") + assert isinstance(obsolete_since_version, str) + assert isinstance(obsolete_since_date, str) + since_date = datetime.date.fromisoformat(obsolete_since_date) + obsolete = ObsoleteMetadata(since_version=obsolete_since_version, since_date=since_date) else: obsolete = None no_longer_updated = data.get("no-longer-updated", False) diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index 926b22c8a620..9b44186ee966 100755 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -22,7 +22,7 @@ from dataclasses import dataclass, field from http import HTTPStatus from pathlib import Path -from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypedDict, TypeVar +from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypedDict, TypeVar, cast from typing_extensions import Self, TypeAlias if sys.version_info >= (3, 11): @@ -906,9 +906,9 @@ async def suggest_typeshed_obsolete(obsolete: Obsolete, session: aiohttp.ClientS async with _repo_lock: branch_name = f"{BRANCH_PREFIX}/{normalize(obsolete.distribution)}" subprocess.check_call(["git", "checkout", "-B", branch_name, "origin/main"]) - obs_string = tomlkit.string(obsolete.obsolete_since_version) - obs_string.comment(f"Released on {obsolete.obsolete_since_date.date().isoformat()}") - update_metadata(obsolete.distribution, obsolete_since=obs_string) + obsolete_t = cast(dict[str, object], tomlkit.inline_table()) + obsolete_t.update({"version": obsolete.obsolete_since_version, "date": obsolete.obsolete_since_date.date().isoformat()}) + update_metadata(obsolete.distribution, obsolete_since=obsolete_t) body = "\n".join(f"{k}: {v}" for k, v in obsolete.links.items()) subprocess.check_call(["git", "commit", "--all", "-m", f"{title}\n\n{body}"]) if action_level <= ActionLevel.local: diff --git a/stubs/binaryornot/METADATA.toml b/stubs/binaryornot/METADATA.toml index 3146145847b8..431cf6be18ef 100644 --- a/stubs/binaryornot/METADATA.toml +++ b/stubs/binaryornot/METADATA.toml @@ -1,3 +1,3 @@ version = "0.4.*" upstream-repository = "https://github.com/binaryornot/binaryornot" -obsolete-since = "0.5.0" # Released on 2026-03-07 +obsolete-since = { version = "0.5.0", date = "2026-03-07" } diff --git a/stubs/fpdf2/METADATA.toml b/stubs/fpdf2/METADATA.toml index 98fa4b298c86..bc7b19c18581 100644 --- a/stubs/fpdf2/METADATA.toml +++ b/stubs/fpdf2/METADATA.toml @@ -1,7 +1,7 @@ version = "2.8.4" upstream-repository = "https://github.com/py-pdf/fpdf2" dependencies = ["Pillow>=10.3.0"] -obsolete-since = "2.8.6" # Released on 2026-02-19 +obsolete-since = { version = "2.8.6", date = "2026-02-19" } [tool.stubtest] stubtest-dependencies = ["cryptography"] diff --git a/stubs/icalendar/METADATA.toml b/stubs/icalendar/METADATA.toml index a530386b862a..a835cf4fb948 100644 --- a/stubs/icalendar/METADATA.toml +++ b/stubs/icalendar/METADATA.toml @@ -1,7 +1,7 @@ version = "6.3.2" upstream-repository = "https://github.com/collective/icalendar" dependencies = ["types-python-dateutil", "types-pytz"] -obsolete-since = "7.0.0" # Released on 2026-02-11 +obsolete-since = { version = "7.0.0", date = "2026-02-11" } [tool.stubtest] stubtest-dependencies = ["pytz"]