From 935cd26da244397bf1bc9a21843959456f2b60fe Mon Sep 17 00:00:00 2001 From: "Jason C. Nucciarone" Date: Fri, 6 Dec 2024 12:05:54 -0500 Subject: [PATCH] fix(slurm_ops): use correct type hints for environment variables getters Environment variable getters can reuturn str or None, not just str. None is returned if the environment variable is not defined in the corresponding environment file. Signed-off-by: Jason C. Nucciarone --- lib/charms/hpc_libs/v0/slurm_ops.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/charms/hpc_libs/v0/slurm_ops.py b/lib/charms/hpc_libs/v0/slurm_ops.py index f249c96..9963bf3 100644 --- a/lib/charms/hpc_libs/v0/slurm_ops.py +++ b/lib/charms/hpc_libs/v0/slurm_ops.py @@ -912,9 +912,10 @@ def __init__(self, *args, **kwargs) -> None: self._env_manager = self._ops_manager.env_manager_for(_ServiceType.SACKD) @property - def config_server(self) -> str: + def config_server(self) -> str | None: """Get the configuration server address of this `sackd` node.""" - return self._env_manager.get("SACKD_CONFIG_SERVER") + result = self._env_manager.get("SACKD_CONFIG_SERVER") + return None if result == "" else result @config_server.setter def config_server(self, addr: str) -> None: @@ -971,7 +972,7 @@ def group(self) -> str: return "root" @property - def config_server(self) -> str: + def config_server(self) -> str | None: """Get the configuration server address of this `slurmd` node.""" return self._env_manager.get("SLURMD_CONFIG_SERVER") @@ -1000,7 +1001,7 @@ def __init__(self, *args, **kwargs) -> None: ) @property - def mysql_unix_port(self) -> str: + def mysql_unix_port(self) -> str | None: """Get the URI of the unix socket `slurmdbd` uses to communicate with MySQL.""" return self._env_manager.get("MYSQL_UNIX_PORT")