fl4health.utils.config module¶
- exception InvalidConfigError[source]¶
Bases:
ValueError
- narrow_dict_type(dictionary, key, narrow_type_to)[source]¶
Checks if a key exists in dictionary and if so, verify it is of type narrow_type_to.
- Parameters:
- Returns:
The type-checked value at dictionary[key]
- Return type:
T
- Raises:
ValueError – If dictionary[key] is not of type narrow_type_to or if the key is not present in dictionary.
- narrow_dict_type_and_set_attribute(self, dictionary, dictionary_key, attribute_name, narrow_type_to, func=None)[source]¶
Checks a key exists in dictionary, verify its type and sets the corresponding attribute. Optionally, passes narrowed value to function prior to setting attribute. If key is not present in dictionary or dictionary[dictionary_key] has the wrong type, a ValueError is thrown.
- Parameters:
- Raises:
ValueError – If dictionary[key] is not of type narrow_type_to or if the key is not present in dictionary.
- Return type: