def attach_tz_if_none(dt, tz):
    """
    Makes a naive timezone aware or returns it if it is already aware.

    Attaches the timezone tz to the datetime dt if dt has no tzinfo. If
    dt already has tzinfo set, return dt.

    :type dt: datetime
    :param dt: A naive or aware datetime object.

    :type tz: pytz timezone
    :param tz: The timezone to add to the datetime

    :rtype: datetime
    :returns: An aware datetime dt with tzinfo set to tz. If dt already had
        tzinfo set, dt is returned unchanged.
    """
    return tz.localize(dt) if dt.tzinfo is None else dt