pypi: fix sorting with use_pre_release=True

This commit is contained in:
lilydjwg 2020-04-02 20:12:33 +08:00
parent de6fc3b5ba
commit 89fe2988cc

View file

@ -1,6 +1,8 @@
# MIT licensed
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
from pkg_resources import parse_version
from . import conf_cacheable_with_name, session
get_cacheable_conf = conf_cacheable_with_name('pypi')
@ -15,7 +17,10 @@ async def get_version(name, conf, **kwargs):
data = await res.json()
if use_pre_release:
version = sorted(data['releases'].keys())[-1]
version = sorted(
data['releases'].keys(),
key = parse_version,
)[-1]
else:
version = data['info']['version']
return version