From d61ffbd4fdaa6d4426e4482c760d939c731b42da Mon Sep 17 00:00:00 2001 From: Antonyjin Date: Wed, 5 Jun 2024 16:31:21 +0200 Subject: [PATCH] Fix: Hardcoded string for the version of CRN needed to be fix If the fetch of the version wasn't found (Timeout, connectionError, etc ...) There was a hardcoded string that replaced the version field. But this wasn't the best option. Solution: Return Optionnal[str] instead for being able to return a None value --- src/aleph_client/commands/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aleph_client/commands/utils.py b/src/aleph_client/commands/utils.py index 834271b8..1111d8ad 100644 --- a/src/aleph_client/commands/utils.py +++ b/src/aleph_client/commands/utils.py @@ -484,7 +484,7 @@ async def fetch_crn_system(session: aiohttp.ClientSession, node: dict) -> Option return data -async def get_crn_version(session: aiohttp.ClientSession, node: dict) -> str: +async def get_crn_version(session: aiohttp.ClientSession, node: dict) -> Optional[str]: """ Fetches compute node version asynchronously. @@ -496,7 +496,7 @@ async def get_crn_version(session: aiohttp.ClientSession, node: dict) -> str: str: Node version. """ url: str = node["address"] - version: str = "Can't fetch the version" + version = None try: async with async_timeout.timeout(3 * settings.HTTP_REQUEST_TIMEOUT + 3 * settings.HTTP_REQUEST_TIMEOUT * 0.3 * random()):