(config, property_path, value)
return config_copy
Remove an item from a list in config.
Remove an item from a list in config.
Remove an item from a list in config .
def remove_item_from_config(config, property_path, value):
    """
    Remove an item from a list in config.
    """
    path_components = property_path.split(".")

    # Mutate a copy of the config, not config itself
    cur_part = config_copy = deepcopy(config)
    for i, cur_path in enumerate(path_components):
        if i == len(path_components) - 1:
            # Final component, it must be a list and we delete from it
            if cur_path not in cur_part or not _is_list(cur_part[cur_path]):
                raise ValueError(f"{property_path} is not a list")
            cur_part = cur_part[cur_path]
            cur_part.remove(value)
        else:
            if cur_path not in cur_part or not _is_dict(cur_part[cur_path]):
                raise ValueError(f"{property_path} does not exist in config!")
            cur_part = cur_part[cur_path]

    return config_copy
def remove_item_from_config ( config , property_path , value ) : path_components = property_path . split ( "." ) # Mutate a copy of the config, not config itself cur_part = config_copy = deepcopy ( config ) for i , cur_path in enumerate ( path_components ) : if i == len ( path_components ) - 1 : # Final component, it must be a list and we delete from it if cur_path not in cur_part or not _is_list ( cur_part [ cur_path ] ) : raise ValueError ( f"{property_path} is not a list" ) cur_part = cur_part [ cur_path ] cur_part . remove ( value ) else : if cur_path not in cur_part or not _is_dict ( cur_part [ cur_path ] ) : raise ValueError ( f"{property_path} does not exist in config!" ) cur_part = cur_part [ cur_path ] return config_copy