from typing import Mapping


def _deep_update_config(config, updates):
    """ Deep updates a config dict """
    for key, value in updates.iteritems():
        if isinstance(value, Mapping):
            try:
                base = config[key]
            except KeyError:
                base = {}
            config[key] = _deep_update_config(base, value)
        else:
            config[key] = value
    return config