def do_change_notification_settings(user_profile: UserProfile, name: str, value: Union[(bool, int, str)], log: bool=True) -> None:
    'Takes in a UserProfile object, the name of a global notification\n    preference to update, and the value to update to\n    '
    notification_setting_type = UserProfile.notification_setting_types[name]
    assert isinstance(value, notification_setting_type), f'Cannot update {name}: {value} is not an instance of {notification_setting_type}'
    setattr(user_profile, name, value)
    if ((name == 'enable_digest_emails') and (not value)):
        clear_scheduled_emails([user_profile.id], ScheduledEmail.DIGEST)
    user_profile.save(update_fields=[name])
    event = {'type': 'update_global_notifications', 'user': user_profile.email, 'notification_name': name, 'setting': value}
    if log:
        log_event(event)
    send_event(user_profile.realm, event, [user_profile.id])
Takes in a UserProfile object, the name of a global notification
preference to update, and the value to update to
def do_change_notification_settings(user_profile: UserProfile, name: str, value: Union[(bool, int, str)], log: bool=True) -> None:
    'Takes in a UserProfile object, the name of a global notification\n    preference to update, and the value to update to\n    '
    notification_setting_type = UserProfile.notification_setting_types[name]
    assert isinstance(value, notification_setting_type), f'Cannot update {name}: {value} is not an instance of {notification_setting_type}'
    setattr(user_profile, name, value)
    if ((name == 'enable_digest_emails') and (not value)):
        clear_scheduled_emails([user_profile.id], ScheduledEmail.DIGEST)
    user_profile.save(update_fields=[name])
    event = {'type': 'update_global_notifications', 'user': user_profile.email, 'notification_name': name, 'setting': value}
    if log:
        log_event(event)
    send_event(user_profile.realm, event, [user_profile.id])