Skip to content

Commit d175c7f

Browse files
authored
[client] chore(merge): add null checks for backwards compatibilty (#243)
Signed-off-by: Antoine MAZEAS <antoine.mazeas@filigran.io>
1 parent 4b32065 commit d175c7f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

pyoaev/configuration/sources.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def get(cls, env_var: str) -> str | None:
1414
:return: value of the env var, or None if not found
1515
:rtype: str | None
1616
"""
17-
return os.getenv(env_var)
17+
return os.getenv(env_var) if env_var else None
1818

1919

2020
class DictionarySource:
@@ -23,7 +23,7 @@ class DictionarySource:
2323
# this is quite hacky
2424
# it only strictly handles two levels of keys in a dict
2525
@classmethod
26-
def get(cls, config_key_path: list[str], source_dict: dict) -> str | None:
26+
def get(cls, config_key_path: list[str] | None, source_dict: dict) -> str | None:
2727
"""Gets the value for the specified env var
2828
2929
:param config_key_path: the two-level dictionary path to the config key
@@ -34,6 +34,9 @@ def get(cls, config_key_path: list[str], source_dict: dict) -> str | None:
3434
:return: value for the config key at specified path, or None if not found
3535
:rtype: str | None
3636
"""
37+
if config_key_path is None:
38+
return None
39+
3740
assert (
3841
isinstance(config_key_path, list)
3942
and len(config_key_path) == 2

0 commit comments

Comments
 (0)