From d169cc5376b9d3951eda5f504528b564d4cfa2a1 Mon Sep 17 00:00:00 2001 From: Eklavya Sharma Date: Mon, 13 Jun 2016 10:08:14 +0530 Subject: [PATCH] zerver/lib/bulk_create.py: Fix string annotations. Change string type from `str` to `text_type` where required. Also fix clashing annotations. --- zerver/lib/bulk_create.py | 12 ++++++------ zerver/management/commands/initialize_voyager_db.py | 2 +- zilencer/management/commands/populate_db.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/zerver/lib/bulk_create.py b/zerver/lib/bulk_create.py index f459249f9a..48831fde65 100644 --- a/zerver/lib/bulk_create.py +++ b/zerver/lib/bulk_create.py @@ -8,7 +8,7 @@ from zerver.models import Realm, Stream, UserProfile, Huddle, \ from zerver.lib.create_user import create_user_profile def bulk_create_realms(realm_list): - # type: (Iterable[str]) -> None + # type: (Iterable[text_type]) -> None existing_realms = set(r.domain for r in Realm.objects.select_related().all()) realms_to_create = [] @@ -19,7 +19,7 @@ def bulk_create_realms(realm_list): Realm.objects.bulk_create(realms_to_create) def bulk_create_users(realms, users_raw, bot_type=None): - # type: (Mapping[str, Realm], Set[Tuple[str, text_type, text_type, bool]], Optional[int]) -> None + # type: (Mapping[text_type, Realm], Set[Tuple[text_type, text_type, text_type, bool]], Optional[int]) -> None """ Creates and saves a UserProfile with the given email. Has some code based off of UserManage.create_user, but doesn't .save() @@ -36,7 +36,7 @@ def bulk_create_users(realms, users_raw, bot_type=None): # Now create user_profiles profiles_to_create = [] for (email, full_name, short_name, active) in users: - domain = str(resolve_email_to_domain(email)) + domain = resolve_email_to_domain(email) profile = create_user_profile(realms[domain], email, initial_password(email), active, bot_type, full_name, short_name, None, False) @@ -67,7 +67,7 @@ def bulk_create_users(realms, users_raw, bot_type=None): Subscription.objects.bulk_create(subscriptions_to_create) def bulk_create_streams(realms, stream_list): - # type: (Mapping[str, Realm], Iterable[Tuple[str, text_type]]) -> None + # type: (Mapping[text_type, Realm], Iterable[Tuple[text_type, text_type]]) -> None existing_streams = set((stream.realm.domain, stream.name.lower()) for stream in Stream.objects.select_related().all()) streams_to_create = [] @@ -84,7 +84,7 @@ def bulk_create_streams(realms, stream_list): Recipient.objects.bulk_create(recipients_to_create) def bulk_create_clients(client_list): - # type: (Iterable[str]) -> None + # type: (Iterable[text_type]) -> None existing_clients = set(client.name for client in Client.objects.select_related().all()) clients_to_create = [] @@ -95,7 +95,7 @@ def bulk_create_clients(client_list): Client.objects.bulk_create(clients_to_create) def bulk_create_huddles(users, huddle_user_list): - # type: (Dict[str, UserProfile], Iterable[Tuple[Any, ...]]) -> None + # type: (Dict[text_type, UserProfile], Iterable[Iterable[text_type]]) -> None huddles = {} huddles_by_id = {} huddle_set = set() diff --git a/zerver/management/commands/initialize_voyager_db.py b/zerver/management/commands/initialize_voyager_db.py index 243beb3005..80eb23e6ff 100644 --- a/zerver/management/commands/initialize_voyager_db.py +++ b/zerver/management/commands/initialize_voyager_db.py @@ -17,7 +17,7 @@ from six import text_type settings.TORNADO_SERVER = None def create_users(name_list, bot_type=None): - # type: (Iterable[Tuple[text_type, str]], int) -> None + # type: (Iterable[Tuple[text_type, text_type]], int) -> None realms = {} for realm in Realm.objects.all(): realms[realm.domain] = realm diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index 229591868a..4c26a9ea35 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -37,7 +37,7 @@ from typing import Any, Dict, List, IO, Iterable, Mapping, Set, Tuple settings.TORNADO_SERVER = None def create_users(realms, name_list, bot_type=None): - # type: (Mapping[str, Realm], Iterable[Tuple[text_type, str]], int) -> None + # type: (Mapping[text_type, Realm], Iterable[Tuple[text_type, text_type]], int) -> None user_set = set() for full_name, email in name_list: short_name = email_to_username(email) @@ -45,7 +45,7 @@ def create_users(realms, name_list, bot_type=None): bulk_create_users(realms, user_set, bot_type) def create_streams(realms, realm, stream_list): - # type: (Mapping[str, Realm], Realm, Iterable[str]) -> None + # type: (Mapping[text_type, Realm], Realm, Iterable[text_type]) -> None stream_set = set() for stream_name in stream_list: stream_set.add((realm.domain, stream_name))