def merge_dict(d1: dict, d2: dict, keep_none=False) -> dict:
    """Merge d2 into d1, ignoring extra keys in d2"""
    ret = d1.copy()
    for k in d1.keys():
        if k in d2:
            if not keep_none and d2[k] is None:
                continue
            ret[k] = d2[k]
    return ret