Skip to content

Commit d32754c

Browse files
authored
Stubsabot: mark stubs as obsolete, even if the py.typed file was added in a micro version (#10368)
1 parent d2c87ac commit d32754c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

scripts/stubsabot.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ async def release_contains_py_typed(release_to_download: PypiReleaseDownload, *,
180180

181181

182182
async def find_first_release_with_py_typed(pypi_info: PypiInfo, *, session: aiohttp.ClientSession) -> PypiReleaseDownload | None:
183+
"""If the latest release is py.typed, return the first release that included a py.typed file.
184+
185+
If the latest release is not py.typed, return None.
186+
"""
183187
release_iter = (release for release in pypi_info.releases_in_descending_order() if not release.version.is_prerelease)
184188
latest_release = next(release_iter)
185189
# If the latest release is not py.typed, assume none are.
@@ -429,10 +433,10 @@ async def determine_action(stub_path: Path, session: aiohttp.ClientSession) -> U
429433
latest_release = pypi_info.get_latest_release()
430434
latest_version = latest_release.version
431435
spec = packaging.specifiers.SpecifierSet(f"=={stub_info.version_spec}")
432-
if latest_version in spec:
436+
obsolete_since = await find_first_release_with_py_typed(pypi_info, session=session)
437+
if obsolete_since is None and latest_version in spec:
433438
return NoUpdate(stub_info.distribution, "up to date")
434439

435-
obsolete_since = await find_first_release_with_py_typed(pypi_info, session=session)
436440
relevant_version = obsolete_since.version if obsolete_since else latest_version
437441

438442
project_urls = pypi_info.info["project_urls"] or {}

0 commit comments

Comments
 (0)