Set the key on the object to the value if the current value is falsy.

    Because protobuf Messages do not distinguish between unset values and
    falsy ones particularly well, this method treats any falsy value
    (e.g. 0, empty list) as a target to be overwritten, on both Messages
    and dictionaries.

    Args:
        pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
            object.
        key (str): The key on the object in question.
        value (Any): The value to set.

    Raises:
        TypeError: If pb_or_dict is not a Message or Mapping.

def setdefault(pb_or_dict, key, value):
    """Set the key on the object to the value if the current value is falsy.

    Because protobuf Messages do not distinguish between unset values and
    falsy ones particularly well, this method treats any falsy value
    (e.g. 0, empty list) as a target to be overwritten, on both Messages
    and dictionaries.

    Args:
        pb_or_dict (Union[~google.protobuf.message.Message, Mapping]): the
            object.
        key (str): The key on the object in question.
        value (Any): The value to set.

    Raises:
        TypeError: If pb_or_dict is not a Message or Mapping.
    """
    if not get(pb_or_dict, key, default=None):
        set(pb_or_dict, key, value)