def set_username(user_id, new_username):
 user_settings = get_user_settings(user_id, strict=True)
 UserSettings.require_valid_username(new_username)
 if is_username_taken(new_username):
  raise utils.ValidationError(('Sorry, the username "%s" is already taken! Please pick a different one.' % new_username))
 user_settings.username = new_username
 _save_user_settings(user_settings)

def set_username ( user_id , new_username ) : user_settings = get_user_settings ( user_id , strict = True ) UserSettings . require_valid_username ( new_username ) if is_username_taken ( new_username ) : raise utils . ValidationError ( ( 'Sorry, the username "%s" is already taken! Please pick a different one.' % new_username ) ) user_settings . username = new_username _save_user_settings ( user_settings )
updates the username of the user with the given user_id .