1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-22 05:09:12 +00:00

uv_python module: refactor code

This commit is contained in:
Mariam Ahhttouche 2026-02-23 14:32:10 +01:00
parent 77b04b4885
commit 69e68090fd

View file

@ -64,7 +64,7 @@ notes:
- This state does not use C(uv python upgrade).
- The latest patch version installed depends on the C(uv) version, since available Python versions are frozen per C(uv) release.
- RV(python_versions) and RV(python_paths) lengths are always equal to one for this state.
author: Mariam Ahhttouche (@mriamah)
'''
@ -316,8 +316,8 @@ class UV:
valid_results = self._parse_versions(results)
if valid_results:
version = max(valid_results, key=lambda result: result["parsed_version"])
latest_version = version["version"]
path = version["path"] if version["path"] else ""
latest_version = version.get("version", "")
path = version.get("path", "")
return latest_version, path
def _get_installed_versions(self, *args):
@ -340,7 +340,7 @@ class UV:
valid_results =[]
for result in results:
try:
result["parsed_version"] = Version(result["version"])
result["parsed_version"] = Version(result.get("version", ""))
valid_results.append(result)
except InvalidVersion:
continue