import typing


def set_if_exists(d: dict, k: str, v: typing.Any) -> dict:
    """
    Given a dict ``d`` sets the key ``k`` with value of config ``v``, if the config value ``v`` is set
    and return the updated dictionary.

    .. note::

        The input dictionary ``d`` will be mutated.
    """
    if v:
        d[k] = v
    return d