from typing import Dict
from typing import Any


def deep_update(src: Dict[Any, Any], dest: Dict[Any, Any]) -> Dict[Any, Any]:
    """
    Similar to ``dict.update``, except that we also ``deep_update``
    any dictionaries we find inside of the destination. This is useful for
    nested default settings, for instance.

    Args:
        src: The dictionary which should be used for updates in ``dest``
        dest: The target which should be updated in place. This instance is also returned.

    Returns:
        The merged dictionaries.
    """

    for k, v in src.items():
        if isinstance(v, dict):
            if k not in dest:
                dest[k] = {}

            deep_update(v, dest[k])
        else:
            dest[k] = v
    return dest