Skip to content

Commit

Permalink
Merge pull request #292 from JeanChristopheMorinPerso/skip_yanked_pyp…
Browse files Browse the repository at this point in the history
…i_releases

Exclude yanked PyPI releases
  • Loading branch information
lilydjwg authored Feb 10, 2025
2 parents 745f0de + af21f93 commit 7cacd9e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ Check PyPI

source = "pypi"

Check `PyPI <https://pypi.python.org/>`_ for updates.
Check `PyPI <https://pypi.python.org/>`_ for updates. Yanked releases are ignored.

pypi
The name used on PyPI, e.g. ``PySide``.
Expand Down Expand Up @@ -683,7 +683,7 @@ Check crates.io

source = "cratesio"

Check `crates.io <https://crates.io/>`_ for updates.
Check `crates.io <https://crates.io/>`_ for updates. Yanked releases are ignored.

cratesio
The crate name on crates.io, e.g. ``tokio``.
Expand Down
4 changes: 4 additions & 0 deletions nvchecker_source/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (vers := data['releases'][version]) and vers[0]['yanked']:
continue

try:
parsed_version = Version(version)
except InvalidVersion:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ classifiers =

[options]
zip_safe = True
python_requires = >=3.8

packages = find_namespace:
install_requires =
setuptools; python_version<"3.8"
tomli; python_version<"3.11"
structlog
platformdirs
Expand Down
5 changes: 5 additions & 0 deletions tests/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 7cacd9e

Please sign in to comment.