Exclude yanked PyPI releases

Signed-off-by: Jean-Christophe Morin <jean_christophe_morin@hotmail.com>
This commit is contained in:
Jean-Christophe Morin 2025-02-08 16:00:24 -05:00
parent 4364759b29
commit 6f5870787a
2 changed files with 9 additions and 0 deletions

View File

@ -19,6 +19,10 @@ async def get_version(name, conf, *, cache, **kwargs):
data = await cache.get_json(url)
for version in data['releases'].keys():
# Skip versions that are marked as yanked.
if len(data['releases'][version]) != 0 and data['releases'][version][0]['yanked']:
continue
try:
parsed_version = Version(version)
except InvalidVersion:

View File

@ -32,3 +32,8 @@ async def test_pypi_invalid_version(get_version):
"source": "pypi",
})
async def test_pypi_yanked_version(get_version):
assert await get_version("urllib3", {
"source": "pypi",
"include_regex": "^(1\\..*)|(2\\.0\\.[0,1])",
}) == "1.26.20"