diff --git a/analytics/lib/counts.py b/analytics/lib/counts.py index b7f51f707e..e76a7f89fb 100644 --- a/analytics/lib/counts.py +++ b/analytics/lib/counts.py @@ -2,11 +2,11 @@ import time from collections import OrderedDict, defaultdict from datetime import datetime, timedelta import logging -from typing import Any, Callable, Dict, List, \ +from typing import Callable, Dict, List, \ Optional, Tuple, Type, Union from django.conf import settings -from django.db import connection, models +from django.db import connection from django.db.models import F from analytics.models import BaseCount, \ diff --git a/analytics/management/commands/check_analytics_state.py b/analytics/management/commands/check_analytics_state.py index 0bfc5aa657..c9639c6dd2 100644 --- a/analytics/management/commands/check_analytics_state.py +++ b/analytics/management/commands/check_analytics_state.py @@ -1,10 +1,9 @@ -from argparse import ArgumentParser from datetime import timedelta from django.core.management.base import BaseCommand from django.utils.timezone import now as timezone_now -from analytics.models import InstallationCount, installation_epoch, \ +from analytics.models import installation_epoch, \ last_successful_fill from analytics.lib.counts import COUNT_STATS, CountStat from zerver.lib.timestamp import floor_to_hour, floor_to_day, verify_UTC, \ @@ -12,7 +11,6 @@ from zerver.lib.timestamp import floor_to_hour, floor_to_day, verify_UTC, \ from zerver.models import Realm import os -import sys import time from typing import Any, Dict diff --git a/analytics/management/commands/populate_analytics_db.py b/analytics/management/commands/populate_analytics_db.py index e1bbb43c0c..dc3a2c5437 100644 --- a/analytics/management/commands/populate_analytics_db.py +++ b/analytics/management/commands/populate_analytics_db.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from typing import Any, Dict, List, Mapping, Optional, Type, Union +from typing import Any, Dict, List, Mapping, Optional, Type from django.core.management.base import BaseCommand from django.utils.timezone import now as timezone_now @@ -13,7 +13,7 @@ from analytics.models import BaseCount, FillState, RealmCount, UserCount, \ StreamCount, InstallationCount from zerver.lib.actions import do_change_is_admin from zerver.lib.timestamp import floor_to_day -from zerver.models import Realm, UserProfile, Stream, Message, Client, \ +from zerver.models import Realm, UserProfile, Stream, Client, \ RealmAuditLog, Recipient class Command(BaseCommand): diff --git a/analytics/management/commands/realm_stats.py b/analytics/management/commands/realm_stats.py index f41ee54deb..6ddcfce310 100644 --- a/analytics/management/commands/realm_stats.py +++ b/analytics/management/commands/realm_stats.py @@ -2,7 +2,6 @@ import datetime from argparse import ArgumentParser from typing import Any, List -import pytz from django.core.management.base import BaseCommand from django.db.models import Count from django.utils.timezone import now as timezone_now diff --git a/analytics/models.py b/analytics/models.py index f18254bba7..3b40a35700 100644 --- a/analytics/models.py +++ b/analytics/models.py @@ -1,10 +1,10 @@ import datetime -from typing import Any, Dict, Optional, Tuple, Union +from typing import Optional from django.db import models from zerver.lib.timestamp import floor_to_day -from zerver.models import Realm, Recipient, Stream, UserProfile +from zerver.models import Realm, Stream, UserProfile class FillState(models.Model): property = models.CharField(max_length=40, unique=True) # type: str diff --git a/analytics/tests/test_counts.py b/analytics/tests/test_counts.py index e44fbd7a6a..e4727107fa 100644 --- a/analytics/tests/test_counts.py +++ b/analytics/tests/test_counts.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from typing import Any, Dict, List, Optional, Tuple, Type, Union +from typing import Any, Dict, List, Optional, Tuple, Type import ujson from django.apps import apps @@ -10,14 +10,14 @@ from django.test import TestCase from django.utils.timezone import now as timezone_now from django.utils.timezone import utc as timezone_utc -from analytics.lib.counts import COUNT_STATS, CountStat, DataCollector, \ +from analytics.lib.counts import COUNT_STATS, CountStat, \ DependentCountStat, LoggingCountStat, do_aggregate_to_summary_table, \ do_drop_all_analytics_tables, do_drop_single_stat, \ do_fill_count_stat_at_hour, do_increment_logging_stat, \ process_count_stat, sql_data_collector from analytics.models import BaseCount, \ FillState, InstallationCount, RealmCount, StreamCount, \ - UserCount, installation_epoch, last_successful_fill + UserCount, installation_epoch from zerver.lib.actions import do_activate_user, do_create_user, \ do_deactivate_user, do_reactivate_user, update_user_activity_interval, \ do_invite_users, do_revoke_user_invite, do_resend_user_invite_email, \ diff --git a/analytics/tests/test_views.py b/analytics/tests/test_views.py index 097d013b5d..bf618d9ba0 100644 --- a/analytics/tests/test_views.py +++ b/analytics/tests/test_views.py @@ -1,5 +1,5 @@ from datetime import datetime, timedelta -from typing import Dict, List, Optional +from typing import List, Optional import mock from django.utils.timezone import utc @@ -8,8 +8,8 @@ from analytics.lib.counts import COUNT_STATS, CountStat from analytics.lib.time_utils import time_range from analytics.models import FillState, \ RealmCount, UserCount, last_successful_fill -from analytics.views import get_chart_data, rewrite_client_arrays, \ - sort_by_totals, sort_client_labels, stats +from analytics.views import rewrite_client_arrays, \ + sort_by_totals, sort_client_labels from zerver.lib.test_classes import ZulipTestCase from zerver.lib.timestamp import ceiling_to_day, \ ceiling_to_hour, datetime_to_timestamp diff --git a/confirmation/models.py b/confirmation/models.py index e00755f01b..4cc1b5a2fe 100644 --- a/confirmation/models.py +++ b/confirmation/models.py @@ -16,12 +16,11 @@ from django.http import HttpRequest, HttpResponse from django.shortcuts import render from django.utils.timezone import now as timezone_now -from zerver.lib.utils import generate_random_token from zerver.models import PreregistrationUser, EmailChangeStatus, MultiuseInvite, \ UserProfile, Realm from random import SystemRandom import string -from typing import Any, Dict, Optional, Union +from typing import Dict, Optional, Union class ConfirmationKeyException(Exception): WRONG_LENGTH = 1 diff --git a/confirmation/settings.py b/confirmation/settings.py index 779141ab52..5cd4d0bd2b 100644 --- a/confirmation/settings.py +++ b/confirmation/settings.py @@ -2,8 +2,6 @@ # Copyright: (c) 2008, Jarek Zgoda -from typing import Any, Dict - __revision__ = '$Id: settings.py 12 2008-11-23 19:38:52Z jarek.zgoda $' STATUS_ACTIVE = 1 diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.py index f5cb607638..7959d9dfda 100644 --- a/corporate/lib/stripe.py +++ b/corporate/lib/stripe.py @@ -14,7 +14,6 @@ from django.utils.timezone import now as timezone_now from django.core.signing import Signer import stripe -from zerver.lib.exceptions import JsonableError from zerver.lib.logging_util import log_to_file from zerver.lib.timestamp import datetime_to_timestamp, timestamp_to_datetime from zerver.lib.utils import generate_random_token diff --git a/corporate/models.py b/corporate/models.py index 1296478e46..299b7807c1 100644 --- a/corporate/models.py +++ b/corporate/models.py @@ -5,7 +5,7 @@ from typing import Optional from django.db import models from django.db.models import CASCADE -from zerver.models import Realm, RealmAuditLog +from zerver.models import Realm class Customer(models.Model): realm = models.OneToOneField(Realm, on_delete=CASCADE) # type: Realm diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index 2aceaad02c..aa12ce9fee 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta from decimal import Decimal -from functools import partial, wraps +from functools import wraps from mock import Mock, patch import operator import os @@ -11,7 +11,6 @@ import ujson import json from django.core import signing -from django.core.management import call_command from django.core.urlresolvers import get_resolver from django.http import HttpResponse from django.utils.timezone import utc as timezone_utc @@ -19,22 +18,20 @@ from django.utils.timezone import utc as timezone_utc import stripe from zerver.lib.actions import do_deactivate_user, do_create_user, \ - do_activate_user, do_reactivate_user, do_create_realm + do_activate_user, do_reactivate_user from zerver.lib.test_classes import ZulipTestCase from zerver.lib.timestamp import timestamp_to_datetime, datetime_to_timestamp from zerver.models import Realm, UserProfile, get_realm, RealmAuditLog from corporate.lib.stripe import catch_stripe_errors, attach_discount_to_realm, \ get_seat_count, sign_string, unsign_string, \ - BillingError, StripeCardError, StripeConnectionError, stripe_get_customer, \ - DEFAULT_INVOICE_DAYS_UNTIL_DUE, MIN_INVOICED_LICENSES, do_create_stripe_customer, \ - add_months, next_month, next_renewal_date, renewal_amount, \ + BillingError, StripeCardError, stripe_get_customer, \ + MIN_INVOICED_LICENSES, \ + add_months, next_month, \ compute_plan_parameters, update_or_create_stripe_customer, \ process_initial_upgrade, add_plan_renewal_to_license_ledger_if_needed, \ update_license_ledger_if_needed, update_license_ledger_for_automanaged_plan, \ invoice_plan, invoice_plans_as_needed from corporate.models import Customer, CustomerPlan, LicenseLedger -from corporate.views import payment_method_string -import corporate.urls CallableT = TypeVar('CallableT', bound=Callable[..., Any]) diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index ddc32694ef..625f1ae289 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -1,5 +1,4 @@ import itertools -import mock import os import random from typing import Any, Callable, Dict, Iterable, List, \ @@ -21,13 +20,12 @@ from zerver.lib.cache import cache_set from zerver.lib.generate_test_data import create_test_data from zerver.lib.onboarding import create_if_missing_realm_internal_bots from zerver.lib.push_notifications import logger as push_notifications_logger -from zerver.lib.upload import upload_backend from zerver.lib.users import add_service from zerver.lib.url_preview.preview import CACHE_NAME as PREVIEW_CACHE_NAME from zerver.lib.user_groups import create_user_group from zerver.lib.utils import generate_api_key from zerver.models import CustomProfileField, DefaultStream, Message, Realm, RealmAuditLog, \ - RealmDomain, RealmEmoji, Recipient, Service, Stream, Subscription, \ + RealmDomain, Recipient, Service, Stream, Subscription, \ UserMessage, UserPresence, UserProfile, clear_database, \ email_to_username, get_client, get_huddle, get_realm, get_stream, \ get_system_bot, get_user, get_user_profile_by_id diff --git a/zproject/backends.py b/zproject/backends.py index fa8233af56..817a1dca4b 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -1,5 +1,5 @@ import logging -from typing import Any, Dict, List, Set, Tuple, Optional, Sequence +from typing import Any, Dict, List, Set, Tuple, Optional from django_auth_ldap.backend import LDAPBackend, _LDAPUser import django.contrib.auth @@ -14,15 +14,11 @@ from social_core.backends.github import GithubOAuth2, GithubOrganizationOAuth2, from social_core.backends.azuread import AzureADOAuth2 from social_core.backends.base import BaseAuth from social_core.backends.oauth import BaseOAuth2 -from social_core.utils import handle_http_errors from social_core.exceptions import AuthFailed, SocialAuthBaseException -from social_django.models import DjangoStorage -from social_django.strategy import DjangoStrategy from zerver.lib.actions import do_create_user, do_reactivate_user, do_deactivate_user from zerver.lib.dev_ldap_directory import init_fakeldap from zerver.lib.request import JsonableError -from zerver.lib.subdomains import user_matches_subdomain, get_subdomain from zerver.lib.users import check_full_name from zerver.models import PreregistrationUser, UserProfile, Realm, get_default_stream_groups, \ get_user_profile_by_id, remote_user_to_email, email_to_username, get_realm, \ diff --git a/zproject/prod_settings_template.py b/zproject/prod_settings_template.py index f74f71459a..1f18f010d5 100644 --- a/zproject/prod_settings_template.py +++ b/zproject/prod_settings_template.py @@ -401,7 +401,7 @@ EMAIL_GATEWAY_IMAP_FOLDER = "INBOX" # optionally using LDAP as an authentication mechanism. import ldap -from django_auth_ldap.config import LDAPSearch, GroupOfNamesType, LDAPSearchUnion +from django_auth_ldap.config import LDAPSearch ######## # LDAP integration, part 1: Connecting to the LDAP server. diff --git a/zproject/settings.py b/zproject/settings.py index acbff7873a..e12cf0138a 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -12,7 +12,6 @@ ######################################################################## from copy import deepcopy import os -import platform import time import sys from typing import Any, Optional diff --git a/zproject/urls.py b/zproject/urls.py index e35a0af40a..d026c0cea5 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -8,7 +8,7 @@ import os import zerver.forms from zproject import dev_urls from zproject.legacy_urls import legacy_urls -from zerver.views.integrations import IntegrationView, APIView, MarkdownDirectoryView +from zerver.views.integrations import IntegrationView, MarkdownDirectoryView from zerver.lib.integrations import WEBHOOK_INTEGRATIONS from zerver.webhooks import github_dispatcher diff --git a/zthumbor/loaders/helpers.py b/zthumbor/loaders/helpers.py index 3fb372754e..9f68114ed7 100644 --- a/zthumbor/loaders/helpers.py +++ b/zthumbor/loaders/helpers.py @@ -4,13 +4,8 @@ from __future__ import absolute_import import os import re import sys -from six.moves.urllib.parse import urlparse from typing import Any, Text, Tuple, Optional -if False: - # See https://zulip.readthedocs.io/en/latest/testing/mypy.html#mypy-in-production-scripts - from thumbor.context import Context - ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath('__file__')))) sys.path.append(ZULIP_PATH)