-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pypi: fix handling of invalid versions
fixes #273.
- Loading branch information
Showing
3 changed files
with
20 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# MIT licensed | ||
# Copyright (c) 2013-2024 lilydjwg <[email protected]>, et al. | ||
|
||
__version__ = '2.15' | ||
__version__ = '2.15.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
# MIT licensed | ||
# Copyright (c) 2013-2021 lilydjwg <[email protected]>, et al. | ||
# Copyright (c) 2013-2021,2023-2024 lilydjwg <[email protected]>, et al. | ||
|
||
from packaging.version import Version | ||
import structlog | ||
from packaging.version import Version, InvalidVersion | ||
|
||
from nvchecker.api import RichResult | ||
|
||
logger = structlog.get_logger(logger_name=__name__) | ||
|
||
async def get_version(name, conf, *, cache, **kwargs): | ||
ret = [] | ||
|
||
|
@@ -16,7 +19,14 @@ async def get_version(name, conf, *, cache, **kwargs): | |
data = await cache.get_json(url) | ||
|
||
for version in data['releases'].keys(): | ||
parsed_version = Version(version) | ||
try: | ||
parsed_version = Version(version) | ||
except InvalidVersion: | ||
if data['releases'][version]: | ||
# emit a warning if there is something under the invalid version | ||
# sympy has an empty "0.5.13-hg" version | ||
logger.warning('ignoring invalid version', version=version) | ||
continue | ||
|
||
if not use_pre_release and parsed_version.is_prerelease: | ||
continue | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters