1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-23 13:50:30 +00:00

uv_python module: update latest state handling to sort versions without relying on uv behavior

This commit is contained in:
Mariam Ahhttouche 2026-02-16 10:04:38 +01:00
parent 473f758ec1
commit d37009ae7b

View file

@ -103,7 +103,7 @@ class UV:
detected_version = out.split()[0]
latest_version = self._get_latest_patch_release()
if rc == 0 and detected_version == latest_version:
return False, out
return False, latest_version
if self.module.check_mode:
return True, latest_version
@ -124,9 +124,10 @@ class UV:
return rc, out, err
def _get_latest_patch_release(self):
_, out, _ = self._list_python()
result = json.loads(out)
return result[0]["version"] # uv orders versions in descending order
_, out, _ = self._list_python() # uv returns versions in descending order but we sort them just in case future uv behavior changes
results = json.loads(out)
versions = [StrictVersion(result["version"]) for result in results]
return max(versions).__str__()
def main():