From c2a5b5f160355e7e428d7f67eee978071fa947d6 Mon Sep 17 00:00:00 2001 From: rht Date: Thu, 26 Oct 2017 11:36:30 +0200 Subject: [PATCH] zerver/migrations: Use python 3 syntax for typing. --- zerver/migrations/0001_initial.py | 4 +- zerver/migrations/0029_realm_subdomain.py | 3 +- .../0032_verify_all_medium_avatar_images.py | 6 +-- .../0033_migrate_domain_to_realmalias.py | 3 +- .../0037_disallow_null_string_id.py | 3 +- ...041_create_attachments_for_old_messages.py | 4 +- zerver/migrations/0057_realmauditlog.py | 6 +-- .../0060_move_avatars_to_be_uid_based.py | 9 ++-- .../0064_sync_uploads_filesize_with_db.py | 9 ++-- .../0074_fix_duplicate_attachments.py | 3 +- ...0077_add_file_name_field_to_realm_emoji.py | 50 ++++++++----------- .../0079_remove_old_scheduled_jobs.py | 3 +- .../migrations/0081_make_emoji_lowercase.py | 3 +- .../0085_fix_bots_with_none_bot_type.py | 3 +- .../0087_remove_old_scheduled_jobs.py | 3 +- .../0093_subscription_event_log_backfill.py | 6 +-- .../migrations/0097_reactions_emoji_code.py | 3 +- zerver/migrations/0102_convert_muted_topic.py | 3 +- zerver/migrations/0104_fix_unreads.py | 3 +- .../migrations/0108_fix_default_string_id.py | 3 +- .../0109_mark_tutorial_status_finished.py | 3 +- .../0110_stream_is_in_zephyr_realm.py | 3 +- 22 files changed, 50 insertions(+), 86 deletions(-) diff --git a/zerver/migrations/0001_initial.py b/zerver/migrations/0001_initial.py index c8fbfc5326..2d451f896b 100644 --- a/zerver/migrations/0001_initial.py +++ b/zerver/migrations/0001_initial.py @@ -12,8 +12,8 @@ import zerver.models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -def migrate_existing_attachment_data(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def migrate_existing_attachment_data(apps: StateApps, + schema_editor: DatabaseSchemaEditor) -> None: Attachment = apps.get_model('zerver', 'Attachment') Recipient = apps.get_model('zerver', 'Recipient') Stream = apps.get_model('zerver', 'Stream') diff --git a/zerver/migrations/0029_realm_subdomain.py b/zerver/migrations/0029_realm_subdomain.py index 0b71533fd0..3da248e007 100644 --- a/zerver/migrations/0029_realm_subdomain.py +++ b/zerver/migrations/0029_realm_subdomain.py @@ -6,8 +6,7 @@ from django.db.migrations.state import StateApps from django.conf import settings from django.core.exceptions import ObjectDoesNotExist -def set_subdomain_of_default_realm(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def set_subdomain_of_default_realm(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: if settings.DEVELOPMENT: Realm = apps.get_model('zerver', 'Realm') try: diff --git a/zerver/migrations/0032_verify_all_medium_avatar_images.py b/zerver/migrations/0032_verify_all_medium_avatar_images.py index b16a036b4a..4531a42f19 100644 --- a/zerver/migrations/0032_verify_all_medium_avatar_images.py +++ b/zerver/migrations/0032_verify_all_medium_avatar_images.py @@ -18,15 +18,13 @@ import hashlib # from zerver.lib.upload (which would pretty annoying, but would be a # pain) and just using the current version, which doesn't work # since we rearranged the avatars in Zulip 1.6. -def patched_user_avatar_path(user_profile): - # type: (UserProfile) -> Text +def patched_user_avatar_path(user_profile: UserProfile) -> Text: email = user_profile.email user_key = email.lower() + settings.AVATAR_SALT return make_safe_digest(user_key, hashlib.sha1) @patch('zerver.lib.upload.user_avatar_path', patched_user_avatar_path) -def verify_medium_avatar_image(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def verify_medium_avatar_image(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: user_profile_model = apps.get_model('zerver', 'UserProfile') for user_profile in user_profile_model.objects.filter(avatar_source=u"U"): upload_backend.ensure_medium_avatar_image(user_profile) diff --git a/zerver/migrations/0033_migrate_domain_to_realmalias.py b/zerver/migrations/0033_migrate_domain_to_realmalias.py index 539b1e3ebb..20e6f2f300 100644 --- a/zerver/migrations/0033_migrate_domain_to_realmalias.py +++ b/zerver/migrations/0033_migrate_domain_to_realmalias.py @@ -4,8 +4,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -def add_domain_to_realm_alias_if_needed(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def add_domain_to_realm_alias_if_needed(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model('zerver', 'Realm') RealmAlias = apps.get_model('zerver', 'RealmAlias') diff --git a/zerver/migrations/0037_disallow_null_string_id.py b/zerver/migrations/0037_disallow_null_string_id.py index f0a0c8ac05..84bf8b774b 100644 --- a/zerver/migrations/0037_disallow_null_string_id.py +++ b/zerver/migrations/0037_disallow_null_string_id.py @@ -5,8 +5,7 @@ from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db import migrations, models -def set_string_id_using_domain(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def set_string_id_using_domain(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model('zerver', 'Realm') for realm in Realm.objects.all(): if not realm.string_id: diff --git a/zerver/migrations/0041_create_attachments_for_old_messages.py b/zerver/migrations/0041_create_attachments_for_old_messages.py index d4fa924076..2833820b0a 100644 --- a/zerver/migrations/0041_create_attachments_for_old_messages.py +++ b/zerver/migrations/0041_create_attachments_for_old_messages.py @@ -10,8 +10,8 @@ from django.db.migrations.state import StateApps from zerver.lib.upload import attachment_url_re, attachment_url_to_path_id -def check_and_create_attachments(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def check_and_create_attachments(apps: StateApps, + schema_editor: DatabaseSchemaEditor) -> None: STREAM = 2 Message = apps.get_model('zerver', 'Message') Attachment = apps.get_model('zerver', 'Attachment') diff --git a/zerver/migrations/0057_realmauditlog.py b/zerver/migrations/0057_realmauditlog.py index 03ed2fd733..a2cf9d8a9c 100644 --- a/zerver/migrations/0057_realmauditlog.py +++ b/zerver/migrations/0057_realmauditlog.py @@ -10,8 +10,7 @@ import django.db.models.deletion from django.utils.timezone import now as timezone_now -def backfill_user_activations_and_deactivations(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def backfill_user_activations_and_deactivations(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: migration_time = timezone_now() RealmAuditLog = apps.get_model('zerver', 'RealmAuditLog') UserProfile = apps.get_model('zerver', 'UserProfile') @@ -26,8 +25,7 @@ def backfill_user_activations_and_deactivations(apps, schema_editor): event_type='user_deactivated', event_time=migration_time, backfilled=True) -def reverse_code(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: RealmAuditLog = apps.get_model('zerver', 'RealmAuditLog') RealmAuditLog.objects.filter(event_type='user_created').delete() RealmAuditLog.objects.filter(event_type='user_deactivated').delete() diff --git a/zerver/migrations/0060_move_avatars_to_be_uid_based.py b/zerver/migrations/0060_move_avatars_to_be_uid_based.py index d642745d8d..0f9e665563 100644 --- a/zerver/migrations/0060_move_avatars_to_be_uid_based.py +++ b/zerver/migrations/0060_move_avatars_to_be_uid_based.py @@ -15,8 +15,7 @@ import requests import os -def mkdirs(path): - # type: (Text) -> None +def mkdirs(path: Text) -> None: dirname = os.path.dirname(path) if not os.path.isdir(dirname): os.makedirs(dirname) @@ -24,8 +23,7 @@ def mkdirs(path): class MissingAvatarException(Exception): pass -def move_local_file(type, path_src, path_dst): - # type: (Text, Text, Text) -> None +def move_local_file(type: Text, path_src: Text, path_dst: Text) -> None: src_file_path = os.path.join(settings.LOCAL_UPLOADS_DIR, type, path_src) dst_file_path = os.path.join(settings.LOCAL_UPLOADS_DIR, type, path_dst) if os.path.exists(dst_file_path): @@ -37,8 +35,7 @@ def move_local_file(type, path_src, path_dst): mkdirs(dst_file_path) os.rename(src_file_path, dst_file_path) -def move_avatars_to_be_uid_based(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def move_avatars_to_be_uid_based(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: user_profile_model = apps.get_model('zerver', 'UserProfile') if settings.LOCAL_UPLOADS_DIR is not None: for user_profile in user_profile_model.objects.filter(avatar_source=u"U"): diff --git a/zerver/migrations/0064_sync_uploads_filesize_with_db.py b/zerver/migrations/0064_sync_uploads_filesize_with_db.py index 40e1429ca1..1fccd06902 100644 --- a/zerver/migrations/0064_sync_uploads_filesize_with_db.py +++ b/zerver/migrations/0064_sync_uploads_filesize_with_db.py @@ -14,8 +14,7 @@ import os class MissingUploadFileException(Exception): pass -def get_file_size_local(path_id): - # type: (Text) -> int +def get_file_size_local(path_id: Text) -> int: file_path = os.path.join(settings.LOCAL_UPLOADS_DIR, 'files', path_id) try: size = os.path.getsize(file_path) @@ -23,8 +22,7 @@ def get_file_size_local(path_id): raise MissingUploadFileException return size -def sync_filesizes(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def sync_filesizes(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: attachments = apps.get_model('zerver', 'Attachment') if settings.LOCAL_UPLOADS_DIR is not None: for attachment in attachments.objects.all(): @@ -49,8 +47,7 @@ def sync_filesizes(apps, schema_editor): attachment.size = new_size attachment.save(update_fields=["size"]) -def reverse_sync_filesizes(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def reverse_sync_filesizes(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Does nothing""" return None diff --git a/zerver/migrations/0074_fix_duplicate_attachments.py b/zerver/migrations/0074_fix_duplicate_attachments.py index d9e54f281e..91edc0847c 100644 --- a/zerver/migrations/0074_fix_duplicate_attachments.py +++ b/zerver/migrations/0074_fix_duplicate_attachments.py @@ -6,8 +6,7 @@ from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db.models import Count -def fix_duplicate_attachments(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def fix_duplicate_attachments(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Migration 0041 had a bug, where if multiple messages referenced the same attachment, rather than creating a single attachment object for all of them, we would incorrectly create one for each message. diff --git a/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py b/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py index 9ed02767cd..35ed2f4e0e 100644 --- a/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py +++ b/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py @@ -25,8 +25,7 @@ from typing import Dict, Text, Tuple, Optional, Union from six import binary_type -def force_str(s, encoding='utf-8'): - # type: (Union[Text, binary_type], Text) -> str +def force_str(s: Union[Text, binary_type], encoding: Text='utf-8') -> str: """converts a string to a native string""" if isinstance(s, str): return s @@ -39,23 +38,20 @@ def force_str(s, encoding='utf-8'): class Uploader(object): - def __init__(self): - # type: () -> None + def __init__(self) -> None: self.path_template = "{realm_id}/emoji/{emoji_file_name}" self.emoji_size = (64, 64) - def upload_files(self, response, resized_image, dst_path_id): - # type: (Response, binary_type, Text) -> None + def upload_files(self, response: Response, resized_image: binary_type, + dst_path_id: Text) -> None: raise NotImplementedError() - def get_dst_path_id(self, realm_id, url, emoji_name): - # type: (int, Text, Text) -> Tuple[Text,Text] + def get_dst_path_id(self, realm_id: int, url: Text, emoji_name: Text) -> Tuple[Text, Text]: _, image_ext = os.path.splitext(url) file_name = ''.join((emoji_name, image_ext)) return file_name, self.path_template.format(realm_id=realm_id, emoji_file_name=file_name) - def resize_emoji(self, image_data): - # type: (binary_type) -> Optional[binary_type] + def resize_emoji(self, image_data: binary_type) -> Optional[binary_type]: im = Image.open(io.BytesIO(image_data)) format_ = im.format if format_ == 'GIF' and im.is_animated: @@ -65,8 +61,8 @@ class Uploader(object): im.save(out, format_) return out.getvalue() - def upload_emoji(self, realm_id, image_url, emoji_name): - # type: (int, Text, Text) -> Optional[Text] + def upload_emoji(self, realm_id: int, image_url: Text, + emoji_name: Text) -> Optional[Text]: file_name, dst_path_id = self.get_dst_path_id(realm_id, image_url, emoji_name) if image_url.startswith("/"): # Handle relative URLs. @@ -86,25 +82,22 @@ class Uploader(object): class LocalUploader(Uploader): - def __init__(self): - # type: () -> None + def __init__(self) -> None: super(LocalUploader, self).__init__() @staticmethod - def mkdirs(path): - # type: (Text) -> None + def mkdirs(path: Text) -> None: dirname = os.path.dirname(path) if not os.path.isdir(dirname): os.makedirs(dirname) - def write_local_file(self, path, file_data): - # type: (Text, binary_type) -> None + def write_local_file(self, path: Text, file_data: binary_type) -> None: self.mkdirs(path) with open(path, 'wb') as f: f.write(file_data) - def upload_files(self, response, resized_image, dst_path_id): - # type: (Response, binary_type, Text) -> None + def upload_files(self, response: Response, resized_image: binary_type, + dst_path_id: Text) -> None: dst_file = os.path.join(settings.LOCAL_UPLOADS_DIR, 'avatars', dst_path_id) if resized_image: self.write_local_file(dst_file, resized_image) @@ -114,21 +107,20 @@ class LocalUploader(Uploader): class S3Uploader(Uploader): - def __init__(self): - # type: () -> None + def __init__(self) -> None: super(S3Uploader, self).__init__() conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY) bucket_name = settings.S3_AVATAR_BUCKET self.bucket = conn.get_bucket(bucket_name, validate=False) - def upload_to_s3(self, path, file_data, headers): - # type: (Text, binary_type, Optional[Dict[Text, Text]]) -> None + def upload_to_s3(self, path: Text, file_data: binary_type, + headers: Optional[Dict[Text, Text]]) -> None: key = Key(self.bucket) key.key = path key.set_contents_from_string(force_str(file_data), headers=headers) - def upload_files(self, response, resized_image, dst_path_id): - # type: (Response, binary_type, Text) -> None + def upload_files(self, response: Response, resized_image: binary_type, + dst_path_id: Text) -> None: headers = None # type: Optional[Dict[Text, Text]] content_type = response.headers.get(str("Content-Type")) or guess_type(dst_path_id)[0] if content_type: @@ -139,15 +131,13 @@ class S3Uploader(Uploader): self.upload_to_s3(dst_path_id, response.content, headers) self.upload_to_s3('.'.join((dst_path_id, 'original')), response.content, headers) -def get_uploader(): - # type: () -> Uploader +def get_uploader() -> Uploader: if settings.LOCAL_UPLOADS_DIR is None: return S3Uploader() return LocalUploader() -def upload_emoji_to_storage(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def upload_emoji_to_storage(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: realm_emoji_model = apps.get_model('zerver', 'RealmEmoji') uploader = get_uploader() # type: Uploader for emoji in realm_emoji_model.objects.all(): diff --git a/zerver/migrations/0079_remove_old_scheduled_jobs.py b/zerver/migrations/0079_remove_old_scheduled_jobs.py index 621bfeebe4..26947b2dfc 100644 --- a/zerver/migrations/0079_remove_old_scheduled_jobs.py +++ b/zerver/migrations/0079_remove_old_scheduled_jobs.py @@ -5,8 +5,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -def delete_old_scheduled_jobs(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def delete_old_scheduled_jobs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Delete any old scheduled jobs, to handle changes in the format of that table. Ideally, we'd translate the jobs, but it's not really worth the development effort to save a few invitation reminders diff --git a/zerver/migrations/0081_make_emoji_lowercase.py b/zerver/migrations/0081_make_emoji_lowercase.py index 899da87d95..bf989c92ed 100644 --- a/zerver/migrations/0081_make_emoji_lowercase.py +++ b/zerver/migrations/0081_make_emoji_lowercase.py @@ -13,8 +13,7 @@ class Migration(migrations.Migration): ('zerver', '0080_realm_description_length'), ] - def emoji_to_lowercase(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None + def emoji_to_lowercase(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: RealmEmoji = apps.get_model("zerver", "RealmEmoji") emoji = RealmEmoji.objects.all() for e in emoji: diff --git a/zerver/migrations/0085_fix_bots_with_none_bot_type.py b/zerver/migrations/0085_fix_bots_with_none_bot_type.py index e5e1f0e465..37609f8493 100644 --- a/zerver/migrations/0085_fix_bots_with_none_bot_type.py +++ b/zerver/migrations/0085_fix_bots_with_none_bot_type.py @@ -5,8 +5,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -def fix_bot_type(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def fix_bot_type(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model("zerver", "UserProfile") bots = UserProfile.objects.filter(is_bot=True, bot_type=None) for bot in bots: diff --git a/zerver/migrations/0087_remove_old_scheduled_jobs.py b/zerver/migrations/0087_remove_old_scheduled_jobs.py index a3b83a7a38..71c95003b8 100644 --- a/zerver/migrations/0087_remove_old_scheduled_jobs.py +++ b/zerver/migrations/0087_remove_old_scheduled_jobs.py @@ -5,8 +5,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -def delete_old_scheduled_jobs(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def delete_old_scheduled_jobs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Delete any old scheduled jobs, to handle changes in the format of send_email. Ideally, we'd translate the jobs, but it's not really worth the development effort to save a few invitation reminders diff --git a/zerver/migrations/0093_subscription_event_log_backfill.py b/zerver/migrations/0093_subscription_event_log_backfill.py index 4530cb2479..fd0e80629f 100644 --- a/zerver/migrations/0093_subscription_event_log_backfill.py +++ b/zerver/migrations/0093_subscription_event_log_backfill.py @@ -9,8 +9,7 @@ from django.utils.timezone import now as timezone_now from typing import List -def backfill_subscription_log_events(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def backfill_subscription_log_events(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: migration_time = timezone_now() RealmAuditLog = apps.get_model('zerver', 'RealmAuditLog') Subscription = apps.get_model('zerver', 'Subscription') @@ -47,8 +46,7 @@ def backfill_subscription_log_events(apps, schema_editor): RealmAuditLog.objects.bulk_create(objects_to_create) objects_to_create = [] -def reverse_code(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: RealmAuditLog = apps.get_model('zerver', 'RealmAuditLog') RealmAuditLog.objects.filter(event_type='subscription_created').delete() RealmAuditLog.objects.filter(event_type='subscription_deactivated').delete() diff --git a/zerver/migrations/0097_reactions_emoji_code.py b/zerver/migrations/0097_reactions_emoji_code.py index 71f0563aee..9284afd67b 100644 --- a/zerver/migrations/0097_reactions_emoji_code.py +++ b/zerver/migrations/0097_reactions_emoji_code.py @@ -9,8 +9,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -def populate_new_fields(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def populate_new_fields(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: # Open the JSON file which contains the data to be used for migration. MIGRATION_DATA_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "management", "data") path_to_unified_reactions = os.path.join(MIGRATION_DATA_PATH, "unified_reactions.json") diff --git a/zerver/migrations/0102_convert_muted_topic.py b/zerver/migrations/0102_convert_muted_topic.py index a275a701eb..28ae3396e0 100644 --- a/zerver/migrations/0102_convert_muted_topic.py +++ b/zerver/migrations/0102_convert_muted_topic.py @@ -6,8 +6,7 @@ from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db import connection, migrations -def convert_muted_topics(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def convert_muted_topics(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: stream_query = ''' SELECT zerver_stream.name, diff --git a/zerver/migrations/0104_fix_unreads.py b/zerver/migrations/0104_fix_unreads.py index 40696bd6b8..6c72a8f22a 100644 --- a/zerver/migrations/0104_fix_unreads.py +++ b/zerver/migrations/0104_fix_unreads.py @@ -8,8 +8,7 @@ from django.db import migrations from zerver.lib.fix_unreads import fix -def fix_unreads(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def fix_unreads(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model("zerver", "UserProfile") user_profiles = list(UserProfile.objects.filter(is_bot=False)) for user_profile in user_profiles: diff --git a/zerver/migrations/0108_fix_default_string_id.py b/zerver/migrations/0108_fix_default_string_id.py index 4dad07f108..e8e488cadc 100644 --- a/zerver/migrations/0108_fix_default_string_id.py +++ b/zerver/migrations/0108_fix_default_string_id.py @@ -5,8 +5,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -def fix_realm_string_ids(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def fix_realm_string_ids(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model('zerver', 'Realm') if Realm.objects.filter(deactivated=False).count() != 2: return diff --git a/zerver/migrations/0109_mark_tutorial_status_finished.py b/zerver/migrations/0109_mark_tutorial_status_finished.py index a235d2250f..d140195919 100644 --- a/zerver/migrations/0109_mark_tutorial_status_finished.py +++ b/zerver/migrations/0109_mark_tutorial_status_finished.py @@ -3,8 +3,7 @@ from django.db import models, migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -def set_tutorial_status_to_finished(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def set_tutorial_status_to_finished(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model('zerver', 'UserProfile') UserProfile.objects.update(tutorial_status=u'F') diff --git a/zerver/migrations/0110_stream_is_in_zephyr_realm.py b/zerver/migrations/0110_stream_is_in_zephyr_realm.py index 6bee548101..cfc5958318 100644 --- a/zerver/migrations/0110_stream_is_in_zephyr_realm.py +++ b/zerver/migrations/0110_stream_is_in_zephyr_realm.py @@ -4,8 +4,7 @@ from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db import connection, migrations, models -def populate_is_zephyr(apps, schema_editor): - # type: (StateApps, DatabaseSchemaEditor) -> None +def populate_is_zephyr(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model("zerver", "Realm") Stream = apps.get_model("zerver", "Stream")