(key: str)
This method returns the value for the given :param key:.
    Values of non-existing keys are set to their respective default value.
This method returns the value for the given :param key:.
    Values of non-existing keys are set to their respective default value.
This method returns the value for the given : param key : . Values of non - existing keys are set to their respective default value .
def get(key: str) -> Union[bool, int, float, str, Tuple]:
    """This method returns the value for the given :param key:.
    Values of non-existing keys are set to their respective default value."""
    # values are stored as string in the database
    # cast the value to its respective type, defined by the default value, before returning it
    default = defaults[key]
    value = models.Setting.objects.get_or_create(
        key=key, defaults={"value": str(default)}
    )[0].value
    if type(default) in (str, int, float):
        return type(default)(value)
    if type(default) == bool:
        # bool("False") does not return False -> special case for bool
        return value == "True"
    elif type(default) == tuple:
        # evaluate the stored literal
        return literal_eval(value)
def get ( key : str ) -> Union [ bool , int , float , str , Tuple ] : # values are stored as string in the database # cast the value to its respective type, defined by the default value, before returning it default = defaults [ key ] value = models . Setting . objects . get_or_create ( key = key , defaults = { "value" : str ( default ) } ) [ 0 ] . value if type ( default ) in ( str , int , float ) : return type ( default ) ( value ) if type ( default ) == bool : # bool("False") does not return False -> special case for bool return value == "True" elif type ( default ) == tuple : # evaluate the stored literal return literal_eval ( value )