Skip to content

Commit bdbb6ec

Browse files
authored
Structured obsolete_since fields (#15682)
1 parent 6789530 commit bdbb6ec

11 files changed

Lines changed: 23 additions & 21 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ supported:
176176
This defaults to `types-<distribution>` and should only be set in special
177177
cases.
178178
* `upstream-repository` (recommended): The URL of the upstream repository.
179-
* `obsolete-since` (optional): This field is part of our process for
179+
* `obsolete-since` (optional): This table is part of our process for
180180
[removing obsolete third-party libraries](#third-party-library-removal-policy).
181181
It contains the first version of the corresponding library that ships
182-
its own `py.typed` file.
182+
its own `py.typed` file, and the date when that version was released.
183183
* `no-longer-updated` (optional): This field is set to `true` before removing
184184
stubs for other reasons than the upstream library shipping with type
185185
information.

lib/ts_utils/metadata.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import tomlkit
2424
from packaging.requirements import Requirement
2525
from packaging.specifiers import Specifier
26-
from tomlkit.items import String
2726

2827
from .paths import PYPROJECT_PATH, STUBS_PATH, distribution_path
2928

@@ -298,12 +297,15 @@ def read_metadata(distribution: str) -> StubMetadata:
298297
assert num_url_path_parts == 2, bad_github_url_msg
299298

300299
obsolete_since = data.get("obsolete-since")
301-
assert isinstance(obsolete_since, (String, type(None)))
302-
if obsolete_since:
303-
comment = obsolete_since.trivia.comment
304-
since_date_string = comment.removeprefix("# Released on ")
305-
since_date = datetime.date.fromisoformat(since_date_string)
306-
obsolete = ObsoleteMetadata(since_version=obsolete_since, since_date=since_date)
300+
assert isinstance(obsolete_since, (dict, type(None)))
301+
if obsolete_since is not None:
302+
obsolete_table: dict[str, object] = obsolete_since
303+
obsolete_since_version = obsolete_table.get("version")
304+
obsolete_since_date = obsolete_table.get("date")
305+
assert isinstance(obsolete_since_version, str)
306+
assert isinstance(obsolete_since_date, str)
307+
since_date = datetime.date.fromisoformat(obsolete_since_date)
308+
obsolete = ObsoleteMetadata(since_version=obsolete_since_version, since_date=since_date)
307309
else:
308310
obsolete = None
309311
no_longer_updated = data.get("no-longer-updated", False)

scripts/stubsabot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from dataclasses import dataclass, field
2323
from http import HTTPStatus
2424
from pathlib import Path
25-
from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypeAlias, TypedDict, TypeVar
25+
from typing import Annotated, Any, ClassVar, Literal, NamedTuple, TypeAlias, TypedDict, TypeVar, cast
2626
from typing_extensions import Self
2727

2828
if sys.version_info >= (3, 11):
@@ -906,9 +906,9 @@ async def suggest_typeshed_obsolete(obsolete: Obsolete, session: aiohttp.ClientS
906906
async with _repo_lock:
907907
branch_name = f"{BRANCH_PREFIX}/{normalize(obsolete.distribution)}"
908908
subprocess.check_call(["git", "checkout", "-B", branch_name, "origin/main"])
909-
obs_string = tomlkit.string(obsolete.obsolete_since_version)
910-
obs_string.comment(f"Released on {obsolete.obsolete_since_date.date().isoformat()}")
911-
update_metadata(obsolete.distribution, obsolete_since=obs_string)
909+
obsolete_t = cast(dict[str, object], tomlkit.inline_table())
910+
obsolete_t.update({"version": obsolete.obsolete_since_version, "date": obsolete.obsolete_since_date.date().isoformat()})
911+
update_metadata(obsolete.distribution, obsolete_since=obsolete_t)
912912
body = "\n".join(f"{k}: {v}" for k, v in obsolete.links.items())
913913
subprocess.check_call(["git", "commit", "--all", "-m", f"{title}\n\n{body}"])
914914
if action_level <= ActionLevel.local:

stubs/Flask-Cors/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ version = "6.0.3"
22
upstream-repository = "https://github.com/corydolphin/flask-cors"
33
# Requires a version of flask with a `py.typed` file
44
dependencies = ["Flask>=2.0.0"]
5-
obsolete-since = "6.0.4" # Released on 2026-06-07
5+
obsolete-since = { version = "6.0.4", date = "2026-06-07" }

stubs/auth0-python/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version = "4.10.*"
22
upstream-repository = "https://github.com/auth0/auth0-python"
33
dependencies = ["cryptography", "types-requests"]
4-
obsolete-since = "5.4.0" # Released on 2026-05-04
4+
obsolete-since = { version = "5.4.0", date = "2026-05-04" }

stubs/binaryornot/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version = "0.4.*"
22
upstream-repository = "https://github.com/binaryornot/binaryornot"
3-
obsolete-since = "0.5.0" # Released on 2026-03-07
3+
obsolete-since = { version = "0.5.0", date = "2026-03-07" }

stubs/click-spinner/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version = "0.1.11"
22
upstream-repository = "https://github.com/click-contrib/click-spinner"
3-
obsolete-since = "0.2.0" # Released on 2026-06-23
3+
obsolete-since = { version = "0.2.0", date = "2026-06-23" }

stubs/decorator/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version = "5.2.*"
22
upstream-repository = "https://github.com/micheles/decorator"
3-
obsolete-since = "5.3.0" # Released on 2026-05-17
3+
obsolete-since = { version = "5.3.0", date = "2026-05-17" }

stubs/fpdf2/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version = "2.8.4"
22
upstream-repository = "https://github.com/py-pdf/fpdf2"
33
dependencies = ["Pillow>=10.3.0"]
4-
obsolete-since = "2.8.6" # Released on 2026-02-19
4+
obsolete-since = { version = "2.8.6", date = "2026-02-19" }
55

66
[tool.stubtest]
77
stubtest-dependencies = ["cryptography"]

stubs/icalendar/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version = "6.3.2"
22
upstream-repository = "https://github.com/collective/icalendar"
33
dependencies = ["types-python-dateutil", "types-pytz"]
4-
obsolete-since = "7.0.0" # Released on 2026-02-11
4+
obsolete-since = { version = "7.0.0", date = "2026-02-11" }
55

66
[tool.stubtest]
77
stubtest-dependencies = ["pytz"]

0 commit comments

Comments
 (0)