def merge_kwargs(local_kwarg, default_kwarg):
    """Merges kwarg dictionaries.

    If a local key in the dictionary is set to None, it will be removed.
    """
    if default_kwarg is None:
        return local_kwarg
    if isinstance(local_kwarg, str):
        return local_kwarg
    if local_kwarg is None:
        return default_kwarg
    if not hasattr(default_kwarg, 'items'):
        return local_kwarg
    kwargs = default_kwarg.copy()
    kwargs.update(local_kwarg)
    for k, v in list(local_kwarg.items()):
        if v is None:
            del kwargs[k]
    return kwargs
