From 2a2e744b2775baf403a3163fc5d9f00a8e768341 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 2 Feb 2019 14:53:29 -0800 Subject: [PATCH] management: Remove unused imports in management commands. Signed-off-by: Anders Kaseorg --- zerver/management/commands/checkconfig.py | 3 --- zerver/management/commands/convert_gitter_data.py | 2 -- zerver/management/commands/convert_hipchat_data.py | 5 +---- zerver/management/commands/convert_slack_data.py | 2 -- zerver/management/commands/create_large_indexes.py | 3 +-- zerver/management/commands/create_realm_internal_bots.py | 6 +----- zerver/management/commands/create_stream.py | 2 -- zerver/management/commands/deliver_email.py | 1 - zerver/management/commands/deliver_scheduled_messages.py | 2 -- zerver/management/commands/email_mirror.py | 2 +- zerver/management/commands/enqueue_digest_emails.py | 2 +- zerver/management/commands/generate_multiuse_invite_link.py | 1 - zerver/management/commands/import.py | 1 - zerver/management/commands/register_server.py | 2 -- zerver/management/commands/rename_stream.py | 2 -- zerver/management/commands/send_password_reset_email.py | 4 +--- zerver/management/commands/send_realm_reactivation_email.py | 1 - zerver/management/commands/send_to_email_mirror.py | 6 +----- zerver/management/commands/show_admins.py | 5 ----- zerver/management/commands/soft_deactivate_users.py | 2 +- zerver/management/commands/sync_ldap_user_data.py | 1 - 21 files changed, 8 insertions(+), 47 deletions(-) diff --git a/zerver/management/commands/checkconfig.py b/zerver/management/commands/checkconfig.py index 90e862fe6d..be9eaec8ad 100644 --- a/zerver/management/commands/checkconfig.py +++ b/zerver/management/commands/checkconfig.py @@ -1,8 +1,5 @@ - -import sys from typing import Any -from django.conf import settings from django.core.management.base import BaseCommand from zerver.lib.management import check_config diff --git a/zerver/management/commands/convert_gitter_data.py b/zerver/management/commands/convert_gitter_data.py index a33be62117..f10803e79a 100644 --- a/zerver/management/commands/convert_gitter_data.py +++ b/zerver/management/commands/convert_gitter_data.py @@ -1,9 +1,7 @@ import argparse import os -import subprocess import tempfile -import shutil from typing import Any from django.core.management.base import BaseCommand, CommandParser, CommandError diff --git a/zerver/management/commands/convert_hipchat_data.py b/zerver/management/commands/convert_hipchat_data.py index 76ea637957..013102ccc9 100644 --- a/zerver/management/commands/convert_hipchat_data.py +++ b/zerver/management/commands/convert_hipchat_data.py @@ -1,8 +1,5 @@ import argparse import os -import subprocess -import tempfile -import shutil from typing import Any ''' @@ -24,7 +21,7 @@ spec: exporting-from-hipchat-server-or-data-center-for-data-portability-950821555.html ''' -from django.core.management.base import BaseCommand, CommandParser, CommandError +from django.core.management.base import BaseCommand, CommandParser from zerver.data_import.hipchat import do_convert_data diff --git a/zerver/management/commands/convert_slack_data.py b/zerver/management/commands/convert_slack_data.py index 88c7de9575..7457bf0eff 100644 --- a/zerver/management/commands/convert_slack_data.py +++ b/zerver/management/commands/convert_slack_data.py @@ -1,9 +1,7 @@ import argparse import os -import subprocess import tempfile -import shutil from typing import Any from django.core.management.base import BaseCommand, CommandParser, CommandError diff --git a/zerver/management/commands/create_large_indexes.py b/zerver/management/commands/create_large_indexes.py index 1436cd0e31..953e62badd 100644 --- a/zerver/management/commands/create_large_indexes.py +++ b/zerver/management/commands/create_large_indexes.py @@ -1,5 +1,4 @@ - -from typing import Any, Callable, Dict, List, Set +from typing import Any from django.db import connection diff --git a/zerver/management/commands/create_realm_internal_bots.py b/zerver/management/commands/create_realm_internal_bots.py index 31ed015df1..c7c8ae5eb1 100644 --- a/zerver/management/commands/create_realm_internal_bots.py +++ b/zerver/management/commands/create_realm_internal_bots.py @@ -1,12 +1,8 @@ +from typing import Any -from typing import Any, Iterable, Tuple - -from django.conf import settings from django.core.management.base import BaseCommand -from django.db.models import Count from zerver.lib.onboarding import create_if_missing_realm_internal_bots -from zerver.models import Realm, UserProfile class Command(BaseCommand): help = """\ diff --git a/zerver/management/commands/create_stream.py b/zerver/management/commands/create_stream.py index de75e6c4fe..bd04d8eb42 100644 --- a/zerver/management/commands/create_stream.py +++ b/zerver/management/commands/create_stream.py @@ -1,5 +1,3 @@ - -import sys from argparse import ArgumentParser from typing import Any diff --git a/zerver/management/commands/deliver_email.py b/zerver/management/commands/deliver_email.py index 516945f853..3af97e40e0 100644 --- a/zerver/management/commands/deliver_email.py +++ b/zerver/management/commands/deliver_email.py @@ -9,7 +9,6 @@ condition. (Alternatively, you can set `EMAIL_DELIVERER_DISABLED=True` on all but one machine to make the command have no effect.) """ -import os import logging import time from typing import Any diff --git a/zerver/management/commands/deliver_scheduled_messages.py b/zerver/management/commands/deliver_scheduled_messages.py index c9565e9229..88fa93811f 100644 --- a/zerver/management/commands/deliver_scheduled_messages.py +++ b/zerver/management/commands/deliver_scheduled_messages.py @@ -1,5 +1,4 @@ import logging -import os import time from typing import Any, Dict from datetime import timedelta @@ -13,7 +12,6 @@ from zerver.lib.logging_util import log_to_file from zerver.lib.management import sleep_forever from zerver.models import ScheduledMessage, Message, get_user_by_delivery_email from zerver.lib.actions import do_send_messages -from zerver.lib.addressee import Addressee ## Setup ## logger = logging.getLogger(__name__) diff --git a/zerver/management/commands/email_mirror.py b/zerver/management/commands/email_mirror.py index 5974772ff5..bf5e7de4b1 100644 --- a/zerver/management/commands/email_mirror.py +++ b/zerver/management/commands/email_mirror.py @@ -26,7 +26,7 @@ import email import logging from email.message import Message from imaplib import IMAP4_SSL -from typing import Any, Generator, List +from typing import Any, Generator from django.conf import settings from django.core.management.base import BaseCommand diff --git a/zerver/management/commands/enqueue_digest_emails.py b/zerver/management/commands/enqueue_digest_emails.py index b72f25bb14..d99d4d9b61 100644 --- a/zerver/management/commands/enqueue_digest_emails.py +++ b/zerver/management/commands/enqueue_digest_emails.py @@ -1,6 +1,6 @@ import datetime import logging -from typing import Any, List +from typing import Any from django.conf import settings from django.core.management.base import BaseCommand diff --git a/zerver/management/commands/generate_multiuse_invite_link.py b/zerver/management/commands/generate_multiuse_invite_link.py index b04a3a2d36..d071d30582 100644 --- a/zerver/management/commands/generate_multiuse_invite_link.py +++ b/zerver/management/commands/generate_multiuse_invite_link.py @@ -2,7 +2,6 @@ from argparse import ArgumentParser from typing import Any, List -from confirmation.models import Confirmation, create_confirmation_link from zerver.lib.actions import ensure_stream, do_create_multiuse_invite_link from zerver.lib.management import ZulipBaseCommand from zerver.models import Stream diff --git a/zerver/management/commands/import.py b/zerver/management/commands/import.py index 7180e02d93..a4fa051dcd 100644 --- a/zerver/management/commands/import.py +++ b/zerver/management/commands/import.py @@ -2,7 +2,6 @@ import argparse import os import subprocess -import tarfile from typing import Any from django.conf import settings diff --git a/zerver/management/commands/register_server.py b/zerver/management/commands/register_server.py index e6e088280e..d6c05b9210 100644 --- a/zerver/management/commands/register_server.py +++ b/zerver/management/commands/register_server.py @@ -1,9 +1,7 @@ from argparse import ArgumentParser import json -import os import requests import subprocess -import sys from typing import Any from django.conf import settings diff --git a/zerver/management/commands/rename_stream.py b/zerver/management/commands/rename_stream.py index 66c1a6e92b..a7456a02d9 100644 --- a/zerver/management/commands/rename_stream.py +++ b/zerver/management/commands/rename_stream.py @@ -1,5 +1,3 @@ - -import sys from argparse import ArgumentParser from typing import Any diff --git a/zerver/management/commands/send_password_reset_email.py b/zerver/management/commands/send_password_reset_email.py index 4a395cb5ee..f987c01d28 100644 --- a/zerver/management/commands/send_password_reset_email.py +++ b/zerver/management/commands/send_password_reset_email.py @@ -1,7 +1,5 @@ - -import logging from argparse import ArgumentParser -from typing import Any, Dict, List, Optional +from typing import Any, List from django.contrib.auth.tokens import default_token_generator diff --git a/zerver/management/commands/send_realm_reactivation_email.py b/zerver/management/commands/send_realm_reactivation_email.py index 39b1dd91a6..175b196526 100644 --- a/zerver/management/commands/send_realm_reactivation_email.py +++ b/zerver/management/commands/send_realm_reactivation_email.py @@ -2,7 +2,6 @@ from argparse import ArgumentParser from zerver.lib.management import ZulipBaseCommand, CommandError -from zerver.lib.send_email import send_email, FromAddress from zerver.lib.actions import do_send_realm_reactivation_email from typing import Any diff --git a/zerver/management/commands/send_to_email_mirror.py b/zerver/management/commands/send_to_email_mirror.py index 17cc38126d..b142c91c98 100644 --- a/zerver/management/commands/send_to_email_mirror.py +++ b/zerver/management/commands/send_to_email_mirror.py @@ -8,17 +8,13 @@ from email.mime.text import MIMEText from django.conf import settings from django.core.management.base import CommandParser -from django.core.mail import send_mail from zerver.lib.actions import encode_email_address -from zerver.lib.email_mirror import logger, process_message -from zerver.lib.send_email import FromAddress +from zerver.lib.email_mirror import process_message from zerver.lib.management import ZulipBaseCommand from zerver.models import Realm, get_stream, get_realm -from typing import Any, Dict - # This command loads an email from a specified file and sends it # to the email mirror. Simple emails can be passed in a JSON file, # Look at zerver/tests/fixtures/email/1.json for an example of how diff --git a/zerver/management/commands/show_admins.py b/zerver/management/commands/show_admins.py index 7e97af9479..a27de0e1d0 100644 --- a/zerver/management/commands/show_admins.py +++ b/zerver/management/commands/show_admins.py @@ -1,12 +1,7 @@ - -import sys from argparse import ArgumentParser from typing import Any -from django.core.management.base import CommandError - from zerver.lib.management import ZulipBaseCommand -from zerver.models import get_realm class Command(ZulipBaseCommand): help = """Show the admins in a realm.""" diff --git a/zerver/management/commands/soft_deactivate_users.py b/zerver/management/commands/soft_deactivate_users.py index c918f629bc..63d98f2323 100644 --- a/zerver/management/commands/soft_deactivate_users.py +++ b/zerver/management/commands/soft_deactivate_users.py @@ -1,7 +1,7 @@ import sys from argparse import ArgumentParser -from typing import Any, Dict, List +from typing import Any, Dict from django.conf import settings diff --git a/zerver/management/commands/sync_ldap_user_data.py b/zerver/management/commands/sync_ldap_user_data.py index bc127db3e8..4438470000 100644 --- a/zerver/management/commands/sync_ldap_user_data.py +++ b/zerver/management/commands/sync_ldap_user_data.py @@ -6,7 +6,6 @@ from typing import Any, List from django.conf import settings -from django.db.utils import IntegrityError from zerver.lib.logging_util import log_to_file from zerver.lib.management import ZulipBaseCommand