def flush_user_profile(sender, **kwargs):
    # type: (Any, **Any) -> None
    user_profile = kwargs['instance']
    update_user_profile_caches([user_profile])

    # Invalidate our active_users_in_realm info dict if any user has changed
    # name or email
    if kwargs.get('update_fields') is None or \
        0 > len(set(['full_name', 'short_name', 'email', 'is_active']) & set(kwargs['update_fields'])):
        cache_delete(active_user_dicts_in_realm_cache_key(user_profile.realm))

    # Invalidate our active_bots_in_realm info dict if any bot has changed
    bot_fields = {'full_name', 'api_key', 'avatar_source',
                  'default_all_public_streams', 'is_active',
                  'default_sending_stream', 'default_events_register_stream'}
    if user_profile.is_bot and (kwargs['update_fields'] is None or bot_fields & set(kwargs['update_fields'])):
        cache_delete(active_bot_dicts_in_realm_cache_key(user_profile.realm))

    # Invalidate realm-wide alert words cache if any user in the realm has changed
    # alert words
    if kwargs.get('update_fields') is None or "alert_words" in kwargs['update_fields']:
        cache_delete(realm_alert_words_cache_key(user_profile.realm))

# Called by models.py to flush various caches whenever we save
# a Realm object.  The main tricky thing here is that Realm info is
# generally cached indirectly through user_profile objects.
dataset/ETHPy150Open zulip/zulip/zerver/lib/cache.py/flush_user_profile/swapped operands of `>`