def do_create_user(email: str, password: Optional[str], realm: Realm, full_name: str, bot_type: Optional[int]=None, role: Optional[int]=None, bot_owner: Optional[UserProfile]=None, tos_version: Optional[str]=None, timezone: str='', avatar_source: str=UserProfile.AVATAR_FROM_GRAVATAR, default_sending_stream: Optional[Stream]=None, default_events_register_stream: Optional[Stream]=None, default_all_public_streams: Optional[bool]=None, prereg_user: Optional[PreregistrationUser]=None, newsletter_data: Optional[Dict[(str, str)]]=None, default_stream_groups: Sequence[DefaultStreamGroup]=[], source_profile: Optional[UserProfile]=None, realm_creation: bool=False, acting_user: Optional[UserProfile]=None) -> UserProfile:
    user_profile = create_user(email=email, password=password, realm=realm, full_name=full_name, role=role, bot_type=bot_type, bot_owner=bot_owner, tos_version=tos_version, timezone=timezone, avatar_source=avatar_source, default_sending_stream=default_sending_stream, default_events_register_stream=default_events_register_stream, default_all_public_streams=default_all_public_streams, source_profile=source_profile)
    event_time = user_profile.date_joined
    if (not acting_user):
        acting_user = user_profile
    RealmAuditLog.objects.create(realm=user_profile.realm, acting_user=acting_user, modified_user=user_profile, event_type=RealmAuditLog.USER_CREATED, event_time=event_time, extra_data=ujson.dumps({RealmAuditLog.ROLE_COUNT: realm_user_count_by_role(user_profile.realm)}))
    do_increment_logging_stat(user_profile.realm, COUNT_STATS['active_users_log:is_bot:day'], user_profile.is_bot, event_time)
    if settings.BILLING_ENABLED:
        update_license_ledger_if_needed(user_profile.realm, event_time)
    notify_created_user(user_profile)
    if (bot_type is None):
        process_new_human_user(user_profile, prereg_user=prereg_user, newsletter_data=newsletter_data, default_stream_groups=default_stream_groups, realm_creation=realm_creation)
    return user_profile
def do_create_user(email: str, password: Optional[str], realm: Realm, full_name: str, bot_type: Optional[int]=None, role: Optional[int]=None, bot_owner: Optional[UserProfile]=None, tos_version: Optional[str]=None, timezone: str=, avatar_source: str=UserProfile.AVATAR_FROM_GRAVATAR, default_sending_stream: Optional[Stream]=None, default_events_register_stream: Optional[Stream]=None, default_all_public_streams: Optional[bool]=None, prereg_user: Optional[PreregistrationUser]=None, newsletter_data: Optional[Dict[(str, str)]]=None, default_stream_groups: Sequence[DefaultStreamGroup]=[], source_profile: Optional[UserProfile]=None, realm_creation: bool=False, acting_user: Optional[UserProfile]=None) -> UserProfile:
    user_profile = create_user(email=email, password=password, realm=realm, full_name=full_name, role=role, bot_type=bot_type, bot_owner=bot_owner, tos_version=tos_version, timezone=timezone, avatar_source=avatar_source, default_sending_stream=default_sending_stream, default_events_register_stream=default_events_register_stream, default_all_public_streams=default_all_public_streams, source_profile=source_profile)
    event_time = user_profile.date_joined
    if (not acting_user):
        acting_user = user_profile
    RealmAuditLog.objects.create(realm=user_profile.realm, acting_user=acting_user, modified_user=user_profile, event_type=RealmAuditLog.USER_CREATED, event_time=event_time, extra_data=ujson.dumps({RealmAuditLog.ROLE_COUNT: realm_user_count_by_role(user_profile.realm)}))
    do_increment_logging_stat(user_profile.realm, COUNT_STATS['active_users_log:is_bot:day'], user_profile.is_bot, event_time)
    if settings.BILLING_ENABLED:
        update_license_ledger_if_needed(user_profile.realm, event_time)
    notify_created_user(user_profile)
    if (bot_type is None):
        process_new_human_user(user_profile, prereg_user=prereg_user, newsletter_data=newsletter_data, default_stream_groups=default_stream_groups, realm_creation=realm_creation)
    return user_profile