zerver/lib: Change use of typing.Text to str.

This commit is contained in:
Aditya Bansal
2018-05-11 05:10:23 +05:30
committed by Tim Abbott
parent 5416d137d3
commit a68376e2ba
30 changed files with 262 additions and 262 deletions

View File

@@ -7,9 +7,9 @@ import ujson
import os
import string
from typing import Optional, Text
from typing import Optional
def random_api_key() -> Text:
def random_api_key() -> str:
choices = string.ascii_letters + string.digits
altchars = ''.join([choices[ord(os.urandom(1)) % 62] for _ in range(2)]).encode("utf-8")
return base64.b64encode(os.urandom(24), altchars=altchars).decode("utf-8")
@@ -21,12 +21,12 @@ def random_api_key() -> Text:
# Only use this for bulk_create -- for normal usage one should use
# create_user (below) which will also make the Subscription and
# Recipient objects
def create_user_profile(realm: Realm, email: Text, password: Optional[Text],
active: bool, bot_type: Optional[int], full_name: Text,
short_name: Text, bot_owner: Optional[UserProfile],
is_mirror_dummy: bool, tos_version: Optional[Text],
timezone: Optional[Text],
tutorial_status: Optional[Text] = UserProfile.TUTORIAL_WAITING,
def create_user_profile(realm: Realm, email: str, password: Optional[str],
active: bool, bot_type: Optional[int], full_name: str,
short_name: str, bot_owner: Optional[UserProfile],
is_mirror_dummy: bool, tos_version: Optional[str],
timezone: Optional[str],
tutorial_status: Optional[str] = UserProfile.TUTORIAL_WAITING,
enter_sends: bool = False) -> UserProfile:
now = timezone_now()
email = UserManager.normalize_email(email)
@@ -51,12 +51,12 @@ def create_user_profile(realm: Realm, email: Text, password: Optional[Text],
user_profile.api_key = random_api_key()
return user_profile
def create_user(email: Text, password: Optional[Text], realm: Realm,
full_name: Text, short_name: Text, active: bool = True,
def create_user(email: str, password: Optional[str], realm: Realm,
full_name: str, short_name: str, active: bool = True,
is_realm_admin: bool = False, bot_type: Optional[int] = None,
bot_owner: Optional[UserProfile] = None,
tos_version: Optional[Text] = None, timezone: Text = "",
avatar_source: Text = UserProfile.AVATAR_FROM_GRAVATAR,
tos_version: Optional[str] = None, timezone: str = "",
avatar_source: str = UserProfile.AVATAR_FROM_GRAVATAR,
is_mirror_dummy: bool = False,
default_sending_stream: Optional[Stream] = None,
default_events_register_stream: Optional[Stream] = None,