def merge_dicts(dict1, dict2, deep_merge=True):
    """Merge dict2 into dict1."""
    if deep_merge:
        if isinstance(dict1, list) and isinstance(dict2, list):
            return dict1 + dict2

        if not isinstance(dict1, dict) or not isinstance(dict2, dict):
            return dict2

        for key in dict2:
            dict1[key] = merge_dicts(dict1[key], dict2[key]) if key in dict1 else dict2[key]  # noqa pylint: disable=line-too-long
        return dict1
    dict3 = dict1.copy()
    dict3.update(dict2)
    return dict3
def merge_dicts ( dict1 , dict2 , deep_merge = True ) : if deep_merge : if isinstance ( dict1 , list ) and isinstance ( dict2 , list ) : return dict1 + dict2 if not isinstance ( dict1 , dict ) or not isinstance ( dict2 , dict ) : return dict2 for key in dict2 : dict1 [ key ] = merge_dicts ( dict1 [ key ] , dict2 [ key ] ) if key in dict1 else dict2 [ key ] return dict1 dict3 = dict1 . copy ( ) dict3 . update ( dict2 ) return dict3
Merge dict2 into dict1.