mirror of https://github.com/zulip/zulip.git
zerver core: Remove unused imports.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
parent
3968fe9fdf
commit
f0ecb93515
|
@ -1,5 +1,5 @@
|
|||
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, Optional
|
||||
from django.http import HttpRequest
|
||||
from django.conf import settings
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import django_otp
|
||||
from two_factor.utils import default_device
|
||||
from django_otp import user_has_device, _user_is_authenticated
|
||||
from django_otp.conf import settings as otp_settings
|
||||
|
||||
from django.contrib.auth.decorators import user_passes_test as django_user_passes_test
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
|
@ -29,8 +28,7 @@ from zerver.lib.types import ViewFuncT
|
|||
|
||||
from zerver.lib.rate_limiter import incr_ratelimit, is_ratelimited, \
|
||||
api_calls_left, RateLimitedUser, RateLimiterLockingException
|
||||
from zerver.lib.request import REQ, has_request_variables, JsonableError, RequestVariableMissingError
|
||||
from django.core.handlers import base
|
||||
from zerver.lib.request import REQ, has_request_variables, RequestVariableMissingError
|
||||
|
||||
from functools import wraps
|
||||
import base64
|
||||
|
@ -40,7 +38,7 @@ import logging
|
|||
from io import BytesIO
|
||||
import urllib
|
||||
|
||||
from typing import Union, Any, Callable, Sequence, Dict, Optional, TypeVar, Tuple, cast
|
||||
from typing import Union, Any, Callable, Dict, Optional, TypeVar, Tuple
|
||||
from zerver.lib.logging_util import log_to_file
|
||||
|
||||
# This is a hack to ensure that RemoteZulipServer always exists even
|
||||
|
|
|
@ -7,10 +7,8 @@ from django.contrib.auth.forms import SetPasswordForm, AuthenticationForm, \
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.urls import reverse
|
||||
from django.core.validators import validate_email
|
||||
from django.db.models.query import QuerySet
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.contrib.auth.tokens import default_token_generator
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.utils.http import urlsafe_base64_encode
|
||||
from django.utils.encoding import force_bytes
|
||||
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
||||
|
@ -22,7 +20,7 @@ from zerver.lib.actions import do_change_password, email_not_system_bot, \
|
|||
from zerver.lib.name_restrictions import is_reserved_subdomain, is_disposable_domain
|
||||
from zerver.lib.request import JsonableError
|
||||
from zerver.lib.send_email import send_email, FromAddress
|
||||
from zerver.lib.subdomains import get_subdomain, user_matches_subdomain, is_root_domain_available
|
||||
from zerver.lib.subdomains import get_subdomain, is_root_domain_available
|
||||
from zerver.lib.users import check_full_name
|
||||
from zerver.models import Realm, get_user_by_delivery_email, UserProfile, get_realm, \
|
||||
email_to_domain, \
|
||||
|
@ -34,7 +32,7 @@ import logging
|
|||
import re
|
||||
import DNS
|
||||
|
||||
from typing import Any, Callable, List, Optional, Dict
|
||||
from typing import Any, List, Optional, Dict
|
||||
from two_factor.forms import AuthenticationTokenForm as TwoFactorAuthenticationTokenForm
|
||||
from two_factor.utils import totp_digits
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from typing import (
|
||||
AbstractSet, Any, AnyStr, Callable, Dict, Iterable, List, Mapping, MutableMapping,
|
||||
Optional, Sequence, Set, Tuple, TypeVar, Union, cast
|
||||
AbstractSet, Any, Callable, Dict, Iterable, List, Mapping, MutableMapping,
|
||||
Optional, Sequence, Set, Tuple, Union, cast
|
||||
)
|
||||
from mypy_extensions import TypedDict
|
||||
|
||||
|
@ -77,7 +77,6 @@ from zerver.lib.users import (
|
|||
check_bot_name_available,
|
||||
check_full_name,
|
||||
get_api_key,
|
||||
user_ids_to_users
|
||||
)
|
||||
from zerver.lib.user_status import (
|
||||
update_user_status,
|
||||
|
@ -88,10 +87,10 @@ from zerver.models import Realm, RealmEmoji, Stream, UserProfile, UserActivity,
|
|||
RealmDomain, Service, SubMessage, \
|
||||
Subscription, Recipient, Message, Attachment, UserMessage, RealmAuditLog, \
|
||||
UserHotspot, MultiuseInvite, ScheduledMessage, UserStatus, \
|
||||
Client, DefaultStream, DefaultStreamGroup, UserPresence, PushDeviceToken, \
|
||||
Client, DefaultStream, DefaultStreamGroup, UserPresence, \
|
||||
ScheduledEmail, MAX_TOPIC_NAME_LENGTH, \
|
||||
MAX_MESSAGE_LENGTH, get_client, get_stream, get_personal_recipient, get_huddle, \
|
||||
get_user_profile_by_id, PreregistrationUser, get_display_recipient, \
|
||||
MAX_MESSAGE_LENGTH, get_client, get_stream, get_personal_recipient, \
|
||||
get_user_profile_by_id, PreregistrationUser, \
|
||||
get_realm, bulk_get_recipients, get_stream_recipient, get_stream_recipients, \
|
||||
email_allowed_for_realm, email_to_username, display_recipient_cache_key, \
|
||||
get_user_by_delivery_email, get_stream_cache_key, active_non_guest_user_ids, \
|
||||
|
@ -101,7 +100,7 @@ from zerver.models import Realm, RealmEmoji, Stream, UserProfile, UserActivity,
|
|||
Reaction, EmailChangeStatus, CustomProfileField, \
|
||||
custom_profile_fields_for_realm, get_huddle_user_ids, \
|
||||
CustomProfileFieldValue, validate_attachment_request, get_system_bot, \
|
||||
get_display_recipient_by_id, query_for_ids, get_huddle_recipient, \
|
||||
query_for_ids, get_huddle_recipient, \
|
||||
UserGroup, UserGroupMembership, get_default_stream_groups, \
|
||||
get_bot_services, get_bot_dicts_in_realm, DomainNotAllowedForRealmError, \
|
||||
DisposableEmailError, EmailContainsPlusError, \
|
||||
|
@ -130,23 +129,21 @@ from zerver.lib.utils import generate_api_key
|
|||
from zerver.lib.create_user import create_user
|
||||
from zerver.lib import bugdown
|
||||
from zerver.lib.cache import cache_with_key, cache_set, \
|
||||
user_profile_by_email_cache_key, user_profile_cache_key, \
|
||||
user_profile_by_email_cache_key, \
|
||||
cache_set_many, cache_delete, cache_delete_many
|
||||
from zerver.decorator import statsd_increment
|
||||
from zerver.lib.utils import log_statsd_event, statsd
|
||||
from zerver.lib.html_diff import highlight_html_differences
|
||||
from zerver.lib.i18n import get_language_name
|
||||
from zerver.lib.alert_words import user_alert_words, add_user_alert_words, \
|
||||
from zerver.lib.alert_words import add_user_alert_words, \
|
||||
remove_user_alert_words, set_user_alert_words
|
||||
from zerver.lib.notifications import clear_scheduled_emails, \
|
||||
clear_scheduled_invitation_emails, enqueue_welcome_emails
|
||||
from zerver.lib.narrow import check_supported_events_narrow_filter
|
||||
from zerver.lib.exceptions import JsonableError, ErrorCode, BugdownRenderingException
|
||||
from zerver.lib.sessions import delete_user_sessions
|
||||
from zerver.lib.upload import attachment_url_re, attachment_url_to_path_id, \
|
||||
claim_attachment, delete_message_image, upload_emoji_image, delete_avatar_image
|
||||
from zerver.lib.video_calls import request_zoom_video_call_url
|
||||
from zerver.tornado.event_queue import request_event_queue, send_event
|
||||
from zerver.tornado.event_queue import send_event
|
||||
from zerver.lib.types import ProfileFieldData
|
||||
|
||||
from analytics.models import StreamCount
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
|
||||
from typing import Iterable, List, Optional, Sequence, Union, cast
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.lib.request import JsonableError
|
||||
from zerver.models import (
|
||||
Realm,
|
||||
UserProfile,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from typing import Dict, Any, Optional, Iterable
|
||||
from io import StringIO
|
||||
|
||||
import json
|
||||
import os
|
||||
|
|
|
@ -1,27 +1,18 @@
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
import re
|
||||
import importlib
|
||||
from zerver.lib.actions import internal_send_private_message, \
|
||||
internal_send_stream_message, internal_send_huddle_message
|
||||
from zerver.models import UserProfile, get_active_user
|
||||
from zerver.lib.bot_storage import get_bot_storage, set_bot_storage, \
|
||||
is_key_in_bot_storage, get_bot_storage_size, remove_bot_storage
|
||||
is_key_in_bot_storage, remove_bot_storage
|
||||
from zerver.lib.bot_config import get_bot_config, ConfigError
|
||||
from zerver.lib.integrations import EMBEDDED_BOTS
|
||||
from zerver.lib.topic import get_topic_from_message_info
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
import configparser
|
||||
|
||||
from mypy_extensions import NoReturn
|
||||
from typing import Any, Optional, List, Dict
|
||||
from types import ModuleType
|
||||
from typing import Any, Dict
|
||||
|
||||
our_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from typing import Any, Dict, Iterable, List, Mapping, Optional, Set, Tuple
|
||||
from typing import Any, Dict, List, Optional, Set, Tuple
|
||||
|
||||
from zerver.lib.initial_password import initial_password
|
||||
from zerver.models import Realm, Stream, UserProfile, Huddle, \
|
||||
Subscription, Recipient, Client, RealmAuditLog, get_huddle_hash
|
||||
from zerver.models import Realm, Stream, UserProfile, \
|
||||
Subscription, Recipient, RealmAuditLog
|
||||
from zerver.lib.create_user import create_user_profile
|
||||
from zerver.lib.bugdown import convert as bugdown_convert
|
||||
|
||||
|
|
|
@ -8,9 +8,8 @@ from django.conf import settings
|
|||
from django.db.models import Q
|
||||
from django.core.cache.backends.base import BaseCache
|
||||
from django.http import HttpRequest
|
||||
from django import template
|
||||
|
||||
from typing import cast, Any, Callable, Dict, Iterable, List, Optional, Union, Set, TypeVar, Tuple
|
||||
from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar, Tuple
|
||||
|
||||
from zerver.lib.utils import statsd, statsd_key, make_safe_digest
|
||||
import time
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.conf import settings
|
|||
from zerver.models import Message, UserProfile, Stream, get_stream_cache_key, \
|
||||
Recipient, get_recipient_cache_key, Client, get_client_cache_key, \
|
||||
Huddle, huddle_hash_cache_key
|
||||
from zerver.lib.cache import cache_with_key, cache_set, \
|
||||
from zerver.lib.cache import \
|
||||
user_profile_by_api_key_cache_key, \
|
||||
user_profile_cache_key, get_remote_cache_time, get_remote_cache_requests, \
|
||||
cache_set_many, to_dict_cache_key_id
|
||||
|
|
|
@ -6,10 +6,7 @@ from zerver.lib.upload import copy_avatar
|
|||
from zerver.lib.hotspots import copy_hotpots
|
||||
from zerver.lib.utils import generate_api_key
|
||||
|
||||
import base64
|
||||
import ujson
|
||||
import os
|
||||
import string
|
||||
|
||||
from typing import Optional
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Any, Callable, Dict, Iterable, List, Set, Tuple, Union
|
||||
from typing import Any, Dict, List, Set, Tuple, Union
|
||||
|
||||
from collections import defaultdict
|
||||
import datetime
|
||||
|
@ -6,7 +6,6 @@ import logging
|
|||
import pytz
|
||||
|
||||
from django.db.models import Q, QuerySet
|
||||
from django.template import loader
|
||||
from django.conf import settings
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
||||
|
@ -14,7 +13,7 @@ from confirmation.models import one_click_unsubscribe_link
|
|||
from zerver.lib.notifications import build_message_list
|
||||
from zerver.lib.send_email import send_future_email, FromAddress
|
||||
from zerver.lib.url_encoding import encode_stream
|
||||
from zerver.models import UserProfile, UserMessage, Recipient, Stream, \
|
||||
from zerver.models import UserProfile, UserMessage, Recipient, \
|
||||
Subscription, UserActivity, get_active_streams, get_user_profile_by_id, \
|
||||
Realm, Message
|
||||
from zerver.context_processors import common_context
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Any, Dict, List, Optional, Union, cast
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
@ -21,8 +21,7 @@ from zerver.lib.utils import generate_random_token
|
|||
from zerver.lib.send_email import FromAddress
|
||||
from zerver.models import Stream, Recipient, \
|
||||
get_user_profile_by_id, get_display_recipient, get_personal_recipient, \
|
||||
Message, Realm, UserProfile, get_system_bot, get_user, MAX_TOPIC_NAME_LENGTH, \
|
||||
MAX_MESSAGE_LENGTH
|
||||
Message, Realm, UserProfile, get_system_bot, get_user
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
# System documented in https://zulip.readthedocs.io/en/latest/subsystems/logging.html
|
||||
|
||||
import logging
|
||||
|
||||
from collections import defaultdict
|
||||
from django.conf import settings
|
||||
from django.core.mail import mail_admins
|
||||
from django.http import HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
from typing import cast, Any, Dict, Optional
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
from zerver.filters import clean_data_from_query_parameters
|
||||
from zerver.models import get_system_bot
|
||||
|
|
|
@ -2,20 +2,18 @@
|
|||
# high-level documentation on how this system works.
|
||||
|
||||
import copy
|
||||
import ujson
|
||||
|
||||
from collections import defaultdict
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.conf import settings
|
||||
from importlib import import_module
|
||||
from typing import (
|
||||
cast, Any, Callable, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union
|
||||
Any, Callable, Dict, Iterable, Optional, Sequence, Set
|
||||
)
|
||||
|
||||
session_engine = import_module(settings.SESSION_ENGINE)
|
||||
|
||||
from zerver.lib.alert_words import user_alert_words
|
||||
from zerver.lib.attachments import user_attachments
|
||||
from zerver.lib.avatar import avatar_url, get_avatar_field
|
||||
from zerver.lib.bot_config import load_bot_config_template
|
||||
from zerver.lib.hotspots import get_next_hotspots
|
||||
|
@ -35,7 +33,6 @@ from zerver.lib.request import JsonableError
|
|||
from zerver.lib.topic import TOPIC_NAME
|
||||
from zerver.lib.topic_mutes import get_topic_mutes
|
||||
from zerver.lib.actions import (
|
||||
validate_user_access_to_subscribers_helper,
|
||||
do_get_streams, get_default_streams_for_realm,
|
||||
gather_subscriptions_helper, get_cross_realm_dicts,
|
||||
get_status_dict, streams_to_dicts_sorted,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from enum import Enum
|
||||
from typing import Any, Dict, List, Optional, Type
|
||||
from typing import Any, Dict, List, Type
|
||||
from mypy_extensions import NoReturn
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
|
|
@ -6,8 +6,7 @@ from typing import Any, Mapping, Optional
|
|||
from zerver.lib.actions import internal_send_message
|
||||
from zerver.lib.send_email import FromAddress
|
||||
from zerver.lib.redis_utils import get_redis_client
|
||||
from zerver.models import get_realm, get_system_bot, \
|
||||
UserProfile, Realm
|
||||
from zerver.models import get_system_bot
|
||||
|
||||
import time
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import itertools
|
||||
import ujson
|
||||
import random
|
||||
from typing import List, Dict, Any, Optional
|
||||
from typing import List, Dict, Any
|
||||
|
||||
def load_config() -> Dict[str, Any]:
|
||||
with open("zerver/tests/fixtures/config.generate_data.json", "r") as infile:
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
import os
|
||||
import pathlib
|
||||
|
||||
from typing import Dict, List, Optional, TypeVar, Any
|
||||
from typing import Dict, List, Optional, Any
|
||||
from django.conf import settings
|
||||
from django.conf.urls import url
|
||||
from django.urls.resolvers import LocaleRegexProvider
|
||||
from django.utils.module_loading import import_string
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.template import loader
|
||||
|
||||
from zerver.templatetags.app_filters import render_markdown_path
|
||||
|
||||
|
||||
"""This module declares all of the (documented) integrations available
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import json
|
||||
from typing import Any, Dict, Iterator, Optional
|
||||
from typing import Any, Iterator
|
||||
|
||||
# Taken from
|
||||
# https://github.com/simplejson/simplejson/blob/8edc82afcf6f7512b05fba32baa536fe756bd273/simplejson/encoder.py#L378-L402
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# Library code for use in management commands
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
from argparse import ArgumentParser, RawTextHelpFormatter
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import os
|
||||
import subprocess
|
||||
import logging
|
||||
import difflib
|
||||
|
||||
class DiffException(Exception):
|
||||
pass
|
||||
|
|
|
@ -16,7 +16,6 @@ from zerver.lib.cache import (
|
|||
generic_bulk_cached_fetch,
|
||||
to_dict_cache_key,
|
||||
to_dict_cache_key_id,
|
||||
cache_set,
|
||||
)
|
||||
from zerver.lib.request import JsonableError
|
||||
from zerver.lib.stream_subscription import (
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
from django.db.models.query import QuerySet
|
||||
from psycopg2.extensions import cursor
|
||||
from typing import Any, Callable, Dict, List, Tuple, TypeVar
|
||||
from typing import List, TypeVar
|
||||
|
||||
import re
|
||||
import time
|
||||
|
||||
CursorObj = TypeVar('CursorObj', bound=cursor)
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
|
||||
from typing import cast, Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple
|
||||
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
||||
|
||||
from confirmation.models import Confirmation, one_click_unsubscribe_link
|
||||
from confirmation.models import one_click_unsubscribe_link
|
||||
from django.conf import settings
|
||||
from django.template import loader
|
||||
from django.utils.timezone import now as timezone_now
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.contrib.auth import get_backends
|
||||
from django_auth_ldap.backend import LDAPBackend
|
||||
|
||||
|
@ -22,21 +20,18 @@ from zerver.models import (
|
|||
Stream,
|
||||
get_display_recipient,
|
||||
UserProfile,
|
||||
get_user,
|
||||
get_user_profile_by_id,
|
||||
receives_offline_email_notifications,
|
||||
get_context_for_message,
|
||||
Message,
|
||||
Realm,
|
||||
)
|
||||
|
||||
from datetime import timedelta, datetime
|
||||
from datetime import timedelta
|
||||
from email.utils import formataddr
|
||||
from lxml.cssselect import CSSSelector
|
||||
import lxml.html
|
||||
import re
|
||||
import subprocess
|
||||
import ujson
|
||||
from collections import defaultdict
|
||||
import pytz
|
||||
|
||||
|
@ -529,7 +524,7 @@ def enqueue_welcome_emails(user: UserProfile, realm_creation: bool=False) -> Non
|
|||
else:
|
||||
context['getting_started_link'] = "https://zulipchat.com"
|
||||
|
||||
from zproject.backends import email_belongs_to_ldap, require_email_format_usernames
|
||||
from zproject.backends import email_belongs_to_ldap
|
||||
|
||||
if email_belongs_to_ldap(user.realm, user.email):
|
||||
context["ldap"] = True
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
|
||||
from django.conf import settings
|
||||
|
||||
from zerver.lib.actions import set_default_streams, bulk_add_subscriptions, \
|
||||
from zerver.lib.actions import set_default_streams, \
|
||||
internal_prep_stream_message, internal_send_private_message, \
|
||||
create_stream_if_needed, create_streams_if_needed, do_send_messages, \
|
||||
create_streams_if_needed, do_send_messages, \
|
||||
do_add_reaction_legacy, create_users, missing_any_realm_internal_bots
|
||||
from zerver.lib.topic import get_turtle_message
|
||||
from zerver.models import Realm, UserProfile, Message, Reaction, get_system_bot
|
||||
from zerver.models import Realm, UserProfile, get_system_bot
|
||||
|
||||
from typing import Any, Dict, List, Mapping
|
||||
|
||||
|
|
|
@ -1,24 +1,18 @@
|
|||
from typing import Any, AnyStr, Iterable, Dict, Tuple, Callable, Mapping, Optional
|
||||
from typing import Any, AnyStr, Dict, Optional
|
||||
|
||||
import requests
|
||||
import json
|
||||
import sys
|
||||
import inspect
|
||||
import logging
|
||||
import re
|
||||
import urllib
|
||||
from functools import reduce
|
||||
from requests import Response
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.models import Realm, UserProfile, get_user_profile_by_id, get_client, \
|
||||
from zerver.models import UserProfile, get_user_profile_by_id, get_client, \
|
||||
GENERIC_INTERFACE, Service, SLACK_INTERFACE, email_to_domain
|
||||
from zerver.lib.actions import check_send_message
|
||||
from zerver.lib.queue import retry_event
|
||||
from zerver.lib.topic import get_topic_from_message_info
|
||||
from zerver.lib.url_encoding import near_message_url
|
||||
from zerver.lib.validator import check_dict, check_string
|
||||
from zerver.decorator import JsonableError
|
||||
|
||||
from version import ZULIP_VERSION
|
||||
|
|
|
@ -2,15 +2,12 @@
|
|||
|
||||
import base64
|
||||
import binascii
|
||||
from functools import partial
|
||||
import logging
|
||||
import lxml.html
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import random
|
||||
|
||||
from typing import Any, Dict, List, Optional, SupportsInt, Tuple, Type, Union, cast
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union, cast
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import IntegrityError, transaction
|
||||
|
@ -18,21 +15,17 @@ from django.utils.timezone import now as timezone_now
|
|||
from django.utils.translation import ugettext as _
|
||||
from gcm import GCM
|
||||
import requests
|
||||
import urllib
|
||||
import ujson
|
||||
|
||||
from zerver.decorator import statsd_increment
|
||||
from zerver.lib.avatar import absolute_avatar_url
|
||||
from zerver.lib.exceptions import ErrorCode, JsonableError
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.lib.message import access_message, huddle_users
|
||||
from zerver.lib.queue import retry_event
|
||||
from zerver.lib.remote_server import send_to_push_bouncer, send_json_to_push_bouncer, \
|
||||
PushNotificationBouncerException
|
||||
from zerver.lib.timestamp import datetime_to_timestamp, timestamp_to_datetime
|
||||
from zerver.lib.utils import generate_random_token
|
||||
from zerver.lib.remote_server import send_to_push_bouncer, send_json_to_push_bouncer
|
||||
from zerver.lib.timestamp import datetime_to_timestamp
|
||||
from zerver.models import PushDeviceToken, Message, Recipient, UserProfile, \
|
||||
UserMessage, get_display_recipient, receives_offline_push_notifications, \
|
||||
receives_online_notifications, receives_stream_notifications, get_user_profile_by_id, \
|
||||
get_display_recipient, receives_offline_push_notifications, \
|
||||
receives_online_notifications, get_user_profile_by_id, \
|
||||
ArchivedMessage
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import os
|
||||
|
||||
from typing import Any, Iterator, List, Optional, Tuple
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from django.conf import settings
|
||||
from zerver.lib.redis_utils import get_redis_client
|
||||
|
@ -10,7 +10,6 @@ from zerver.models import UserProfile
|
|||
|
||||
import redis
|
||||
import time
|
||||
import logging
|
||||
|
||||
# Implement a rate-limiting scheme inspired by the one described here, but heavily modified
|
||||
# http://blog.domaintools.com/2013/04/rate-limiting-with-redis/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.conf import settings
|
||||
|
||||
from zerver.lib.avatar_hash import gravatar_hash, user_avatar_hash
|
||||
from zerver.lib.avatar_hash import gravatar_hash
|
||||
from zerver.lib.upload import upload_backend
|
||||
from zerver.models import Realm
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
from datetime import timedelta
|
||||
|
||||
from django.db import connection, transaction
|
||||
from django.forms.models import model_to_dict
|
||||
from django.utils.timezone import now as timezone_now
|
||||
from zerver.models import Realm, Message, UserMessage, ArchivedMessage, ArchivedUserMessage, \
|
||||
Attachment, ArchivedAttachment
|
||||
|
|
|
@ -13,7 +13,7 @@ import logging
|
|||
import ujson
|
||||
|
||||
import os
|
||||
from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple
|
||||
from typing import Any, Dict, List, Mapping, Optional, Tuple
|
||||
|
||||
from zerver.lib.logging_util import log_to_file
|
||||
from confirmation.models import generate_key
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.utils.timezone import now as timezone_now
|
|||
from typing import DefaultDict, List, Union, Any
|
||||
|
||||
from zerver.models import UserProfile, UserMessage, RealmAuditLog, \
|
||||
Subscription, Message, Recipient, UserActivity, Realm
|
||||
Subscription, Message, Recipient, UserActivity
|
||||
|
||||
logger = logging.getLogger("zulip.soft_deactivation")
|
||||
log_to_file(logger, settings.SOFT_DEACTIVATION_LOG_PATH)
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from zerver.models import UserProfile, UserActivity, UserActivityInterval, Message
|
||||
|
||||
from django.utils.timezone import utc
|
||||
from typing import Any, Dict, List, Sequence, Set
|
||||
from zerver.models import UserProfile, UserActivityInterval
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import (Dict, List, Set)
|
||||
from typing import Set
|
||||
from django.db.models.query import QuerySet
|
||||
|
||||
from zerver.lib.stream_subscription import (
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
from typing import Any, Iterable, List, Mapping, Set, Tuple, Optional
|
||||
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from zerver.lib.actions import check_stream_name, create_streams_if_needed
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from contextlib import contextmanager
|
||||
from typing import (cast, Any, Callable, Dict, Iterable, Iterator, List, Mapping, Optional,
|
||||
Sized, Tuple, Union)
|
||||
from typing import (cast, Any, Dict, Iterable, Iterator, List, Optional,
|
||||
Tuple, Union)
|
||||
|
||||
from django.apps import apps
|
||||
from django.db.migrations.state import StateApps
|
||||
|
@ -24,7 +24,7 @@ from zerver.lib.users import get_api_key
|
|||
|
||||
from zerver.lib.actions import (
|
||||
check_send_message, create_stream_if_needed, bulk_add_subscriptions,
|
||||
get_display_recipient, bulk_remove_subscriptions, do_create_user,
|
||||
bulk_remove_subscriptions,
|
||||
check_send_stream_message, gather_subscriptions,
|
||||
get_default_value_for_history_public_to_subscribers,
|
||||
)
|
||||
|
@ -40,13 +40,13 @@ from zerver.lib.test_helpers import (
|
|||
from zerver.models import (
|
||||
get_stream,
|
||||
get_client,
|
||||
get_display_recipient,
|
||||
get_user,
|
||||
get_realm,
|
||||
Client,
|
||||
Message,
|
||||
Realm,
|
||||
Recipient,
|
||||
Service,
|
||||
Stream,
|
||||
Subscription,
|
||||
UserProfile,
|
||||
|
|
|
@ -1,28 +1,23 @@
|
|||
from contextlib import contextmanager
|
||||
from typing import (
|
||||
cast, Any, Callable, Dict, Generator, Iterable, Iterator, List, Mapping,
|
||||
Optional, Set, Sized, Tuple, Union, IO, TypeVar
|
||||
Any, Callable, Dict, Generator, Iterable, Iterator, List, Mapping,
|
||||
Optional, Tuple, Union, IO, TypeVar
|
||||
)
|
||||
|
||||
from django.core import signing
|
||||
from django.urls.resolvers import LocaleRegexURLResolver
|
||||
from django.conf import settings
|
||||
from django.test import TestCase, override_settings
|
||||
from django.test.client import (
|
||||
BOUNDARY, MULTIPART_CONTENT, encode_multipart,
|
||||
)
|
||||
from django.test import override_settings
|
||||
from django.template import loader
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.db.utils import IntegrityError
|
||||
from django.db.migrations.state import StateApps
|
||||
from boto.s3.connection import Location, S3Connection
|
||||
from boto.s3.connection import S3Connection
|
||||
from boto.s3.bucket import Bucket
|
||||
|
||||
import zerver.lib.upload
|
||||
from zerver.lib.upload import S3UploadBackend, LocalUploadBackend
|
||||
from zerver.lib.avatar import avatar_url
|
||||
from zerver.lib.cache import get_cache_backend
|
||||
from zerver.lib.initial_password import initial_password
|
||||
from zerver.lib.db import TimeTrackingCursor
|
||||
from zerver.lib import cache
|
||||
from zerver.tornado import event_queue
|
||||
|
@ -30,40 +25,29 @@ from zerver.tornado.handlers import allocate_handler_id
|
|||
from zerver.worker import queue_processors
|
||||
|
||||
from zerver.lib.actions import (
|
||||
check_send_message, create_stream_if_needed, bulk_add_subscriptions,
|
||||
get_stream_recipient,
|
||||
)
|
||||
|
||||
from zerver.models import (
|
||||
get_recipient,
|
||||
get_stream,
|
||||
get_user,
|
||||
Client,
|
||||
Message,
|
||||
Realm,
|
||||
Recipient,
|
||||
Stream,
|
||||
Subscription,
|
||||
UserMessage,
|
||||
UserProfile,
|
||||
)
|
||||
|
||||
from zerver.lib.request import JsonableError
|
||||
|
||||
if False:
|
||||
# Avoid an import cycle; we only need these for type annotations.
|
||||
from zerver.lib.test_classes import ZulipTestCase, MigrationsTestCase
|
||||
|
||||
import collections
|
||||
import base64
|
||||
import mock
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import ujson
|
||||
import unittest
|
||||
import urllib
|
||||
from moto import mock_s3_deprecated
|
||||
|
||||
import fakeldap
|
||||
|
@ -581,9 +565,6 @@ def use_db_models(method: Callable[..., None]) -> Callable[..., None]:
|
|||
'zerver.lib.test_helpers',
|
||||
Client=Client,
|
||||
Message=Message,
|
||||
Realm=Realm,
|
||||
Recipient=Recipient,
|
||||
Stream=Stream,
|
||||
Subscription=Subscription,
|
||||
UserMessage=UserMessage,
|
||||
UserProfile=UserProfile,
|
||||
|
@ -595,7 +576,6 @@ def use_db_models(method: Callable[..., None]) -> Callable[..., None]:
|
|||
Message=Message,
|
||||
Realm=Realm,
|
||||
Recipient=Recipient,
|
||||
Service=Service,
|
||||
Stream=Stream,
|
||||
Subscription=Subscription,
|
||||
UserProfile=UserProfile,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
from functools import partial
|
||||
import random
|
||||
|
||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, \
|
||||
Type, cast, Union, TypeVar
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, \
|
||||
Type, cast, TypeVar
|
||||
from unittest import loader, runner # type: ignore # Mypy cannot pick these up.
|
||||
from unittest.result import TestResult
|
||||
|
||||
|
@ -21,15 +21,12 @@ from zerver.lib.rate_limiter import bounce_redis_key_prefix_for_testing
|
|||
from zerver.lib.test_classes import flush_caches_for_testing
|
||||
from zerver.lib.sqlalchemy_utils import get_sqlalchemy_connection
|
||||
from zerver.lib.test_helpers import (
|
||||
get_all_templates, write_instrumentation_reports,
|
||||
write_instrumentation_reports,
|
||||
append_instrumentation_data
|
||||
)
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
import unittest
|
||||
|
||||
from multiprocessing.sharedctypes import Synchronized
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
from typing import Any, Dict, Mapping, Optional, Tuple
|
||||
from typing import Dict, Optional, Tuple
|
||||
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.conf import settings
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.core.files import File
|
||||
from django.http import HttpRequest
|
||||
from django.db.models import Sum
|
||||
|
@ -17,7 +16,7 @@ from boto.s3.key import Key
|
|||
from boto.s3.connection import S3Connection
|
||||
from mimetypes import guess_type, guess_extension
|
||||
|
||||
from zerver.models import get_user_profile_by_id, RealmEmoji
|
||||
from zerver.models import get_user_profile_by_id
|
||||
from zerver.models import Attachment
|
||||
from zerver.models import Realm, RealmEmoji, UserProfile, Message
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from collections import defaultdict
|
||||
from django.db import transaction
|
||||
from django.utils.translation import ugettext as _
|
||||
from zerver.lib.exceptions import JsonableError
|
||||
from zerver.models import UserProfile, Realm, UserGroupMembership, UserGroup
|
||||
from typing import Dict, Iterable, List, Tuple, Any
|
||||
from typing import Dict, List, Any
|
||||
|
||||
def access_user_group_by_id(user_group_id: int, user_profile: UserProfile) -> UserGroup:
|
||||
try:
|
||||
|
|
|
@ -2,14 +2,13 @@ from typing import Dict, List, Optional, Union, cast
|
|||
|
||||
from django.db.models.query import QuerySet
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.conf import settings
|
||||
|
||||
from zerver.lib.cache import generic_bulk_cached_fetch, user_profile_cache_key_id, \
|
||||
user_profile_by_id_cache_key
|
||||
from zerver.lib.request import JsonableError
|
||||
from zerver.lib.avatar import avatar_url
|
||||
from zerver.models import UserProfile, Service, Realm, \
|
||||
get_user_profile_by_id, query_for_ids, get_user_profile_by_id_in_realm, \
|
||||
get_user_profile_by_id_in_realm, \
|
||||
CustomProfileField
|
||||
|
||||
from zulip_bots.custom_exceptions import ConfigValidationError
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
|
||||
from typing import Any, Callable, List, Optional, Sequence, TypeVar, Iterable, Set, Tuple
|
||||
import base64
|
||||
import errno
|
||||
import hashlib
|
||||
import heapq
|
||||
import itertools
|
||||
import os
|
||||
import string
|
||||
import sys
|
||||
from time import sleep
|
||||
from itertools import zip_longest
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ import ujson
|
|||
from django.utils.translation import ugettext as _
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import validate_email, URLValidator
|
||||
from typing import Callable, Iterable, Optional, Tuple, TypeVar, cast, \
|
||||
Dict
|
||||
from typing import Iterable, Optional, Tuple, cast
|
||||
|
||||
from datetime import datetime
|
||||
from zerver.lib.request import JsonableError
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from urllib.parse import unquote
|
||||
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest
|
||||
from django.utils.translation import ugettext as _
|
||||
from typing import Optional
|
||||
|
@ -11,7 +10,7 @@ from zerver.lib.exceptions import StreamDoesNotExistError, JsonableError, \
|
|||
ErrorCode
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.send_email import FromAddress
|
||||
from zerver.models import UserProfile, get_system_bot
|
||||
from zerver.models import UserProfile
|
||||
|
||||
|
||||
MISSING_EVENT_HEADER_MESSAGE = """
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from typing import MutableMapping, Any, Optional, List, Tuple
|
||||
from django.conf import settings
|
||||
from typing import MutableMapping, Any, Optional, Tuple
|
||||
|
||||
import re
|
||||
import json
|
||||
|
|
|
@ -8,10 +8,8 @@ import traceback
|
|||
from typing import Any, Dict, Optional
|
||||
|
||||
from django.conf import settings
|
||||
from django.core import mail
|
||||
from django.http import HttpRequest
|
||||
from django.utils.log import AdminEmailHandler
|
||||
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
|
||||
from django.views.debug import get_exception_reporter_filter
|
||||
|
||||
from zerver.lib.logging_util import find_log_caller_module
|
||||
from zerver.lib.queue import queue_json_publish
|
||||
|
@ -113,7 +111,6 @@ class AdminNotifyHandler(logging.Handler):
|
|||
if record.exc_info:
|
||||
stack_trace = ''.join(traceback.format_exception(*record.exc_info))
|
||||
message = str(record.exc_info[1])
|
||||
from zerver.lib.exceptions import BugdownRenderingException
|
||||
is_bugdown_rendering_exception = record.msg.startswith('Exception in Markdown parser')
|
||||
else:
|
||||
stack_trace = 'No stack trace available'
|
||||
|
|
|
@ -3,7 +3,7 @@ import cProfile
|
|||
import logging
|
||||
import time
|
||||
import traceback
|
||||
from typing import Any, AnyStr, Callable, Dict, \
|
||||
from typing import Any, AnyStr, Dict, \
|
||||
Iterable, List, MutableMapping, Optional
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
@ -13,7 +13,7 @@ from django.contrib.sessions.middleware import SessionMiddleware
|
|||
from django.core.exceptions import DisallowedHost, SuspiciousOperation
|
||||
from django.db import connection
|
||||
from django.http import HttpRequest, HttpResponse, StreamingHttpResponse
|
||||
from django.shortcuts import redirect, render
|
||||
from django.shortcuts import render
|
||||
from django.utils.cache import patch_vary_headers
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from django.utils.http import cookie_date
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
from typing import Any, DefaultDict, Dict, List, Set, Tuple, TypeVar, \
|
||||
Union, Optional, Sequence, AbstractSet, Pattern, AnyStr, Callable, Iterable
|
||||
Union, Optional, Sequence, AbstractSet, Callable, Iterable
|
||||
from typing.re import Match
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.query import QuerySet, F
|
||||
from django.db.models import Manager, CASCADE, Sum
|
||||
from django.db.models.functions import Length
|
||||
from django.db.models.query import QuerySet
|
||||
from django.db.models import Manager, CASCADE
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import AbstractBaseUser, UserManager, \
|
||||
PermissionsMixin
|
||||
|
@ -30,27 +29,23 @@ from zerver.lib.timestamp import datetime_to_timestamp
|
|||
from django.db.models.signals import pre_save, post_save, post_delete
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from zerver.lib import cache
|
||||
from zerver.lib.validator import check_int, check_float, \
|
||||
from zerver.lib.validator import check_int, \
|
||||
check_short_string, check_long_string, validate_choice_field, check_date, \
|
||||
check_url, check_list
|
||||
from zerver.lib.name_restrictions import is_disposable_domain
|
||||
from zerver.lib.types import Validator, ExtendedValidator, \
|
||||
ProfileDataElement, ProfileData, FieldTypeData, FieldElement, \
|
||||
ProfileDataElement, ProfileData, FieldTypeData, \
|
||||
RealmUserValidator
|
||||
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from bitfield import BitField
|
||||
from bitfield.types import BitHandler
|
||||
from collections import defaultdict, OrderedDict
|
||||
from datetime import timedelta
|
||||
import pylibmc
|
||||
import re
|
||||
import logging
|
||||
import sre_constants
|
||||
import time
|
||||
import datetime
|
||||
import sys
|
||||
|
||||
MAX_TOPIC_NAME_LENGTH = 60
|
||||
MAX_MESSAGE_LENGTH = 10000
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
|
||||
from typing import Any, Dict, Optional
|
||||
from typing import Any, Optional
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.signals import user_logged_in
|
||||
from django.dispatch import receiver
|
||||
from django.template import loader
|
||||
from django.utils.timezone import \
|
||||
get_current_timezone_name as timezone_get_current_timezone_name
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
from html import unescape
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
|
@ -7,8 +6,7 @@ import markdown.extensions.admonition
|
|||
import markdown.extensions.codehilite
|
||||
import markdown.extensions.extra
|
||||
import markdown.extensions.toc
|
||||
from django.conf import settings
|
||||
from django.template import Library, engines, loader
|
||||
from django.template import Library, engines
|
||||
from django.utils.safestring import mark_safe
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
|
||||
|
@ -21,7 +19,6 @@ import zerver.lib.bugdown.help_settings_links
|
|||
import zerver.lib.bugdown.help_relative_links
|
||||
import zerver.lib.bugdown.help_emoticon_translations_table
|
||||
import zerver.lib.bugdown.include
|
||||
from zerver.context_processors import zulip_default_context
|
||||
from zerver.lib.cache import ignore_unhashable_lru_cache
|
||||
|
||||
register = Library()
|
||||
|
|
|
@ -14,8 +14,8 @@ from django.db import connection
|
|||
from django.core.handlers.wsgi import WSGIRequest
|
||||
from django.core.handlers.base import BaseHandler
|
||||
from zerver.models import \
|
||||
get_client, get_system_bot, ScheduledEmail, PreregistrationUser, \
|
||||
get_user_profile_by_id, Message, Realm, Service, UserMessage, UserProfile, \
|
||||
get_client, get_system_bot, PreregistrationUser, \
|
||||
get_user_profile_by_id, Message, Realm, UserMessage, UserProfile, \
|
||||
Client
|
||||
from zerver.lib.context_managers import lockfile
|
||||
from zerver.lib.error_notify import do_report_error
|
||||
|
@ -27,7 +27,7 @@ from zerver.lib.push_notifications import handle_push_notification, handle_remov
|
|||
initialize_push_notifications
|
||||
from zerver.lib.actions import do_send_confirmation_email, \
|
||||
do_update_user_activity, do_update_user_activity_interval, do_update_user_presence, \
|
||||
internal_send_message, check_send_message, extract_recipients, \
|
||||
internal_send_message, \
|
||||
render_incoming_message, do_update_embedded_data, do_mark_stream_messages_as_read
|
||||
from zerver.lib.url_preview import preview as url_preview
|
||||
from zerver.lib.digest import handle_digest_email
|
||||
|
@ -35,7 +35,6 @@ from zerver.lib.send_email import send_future_email, send_email_from_dict, \
|
|||
FromAddress, EmailNotDeliveredException, handle_send_email_format_changes
|
||||
from zerver.lib.email_mirror import process_message as mirror_email
|
||||
from zerver.lib.streams import access_stream_by_id
|
||||
from zerver.decorator import JsonableError
|
||||
from zerver.tornado.socket import req_redis_key, respond_send_message
|
||||
from confirmation.models import Confirmation, create_confirmation_link
|
||||
from zerver.lib.db import reset_queries
|
||||
|
@ -56,8 +55,6 @@ import datetime
|
|||
import logging
|
||||
import requests
|
||||
from io import StringIO
|
||||
import re
|
||||
import importlib
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
Loading…
Reference in New Issue