fetch2/crate: move cmp_to_key import to module level
PATCH 1/1 fetch2/crate: move cmp_to_key import to module level
From: Thomas Perrot <[email protected]>
The import was duplicated inside both latest_versionstring() and latest_versionstring_from_index(). Move it to the top of the module.
Signed-off-by Thomas Perrot <[email protected]>
--- lib/bb/fetch2/crate.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/bb/fetch2/crate.py +1 -3
@@ -14,6 +14,7 @@ import hashlib import json import os import subprocess +from functools import cmp_to_key import bb from bb.fetch2 import logger, subprocess_setup, UnpackError from bb.fetch2.wget import Wget
@@ -159,7 +160,6 @@ class Crate(Wget): """ Return the latest version available when versionsurl is the [name]/versions URL. """ - from functools import cmp_to_key json_data = json.loads(self._fetch_index(ud.versionsurl, ud, d)) versions = [(0, i["num"], "") for i in json_data["versions"]] versions = sorted(versions, key=cmp_to_key(bb.utils.vercmp))
@@ -172,8 +172,6 @@ class Crate(Wget): file. https://doc.rust-lang.org/cargo/reference/registry-index.html#index-files """ - from functools import cmp_to_key - versions = [] response = self._fetch_index(ud.versionsurl, ud, d) for line in response.splitlines():
Signature · 1 line
2.54.0