mirror of https://github.com/zulip/zulip.git
python: Combine some split import groups.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
b2cb992d9f
commit
3916ea23a9
|
@ -57,11 +57,6 @@ from zerver.lib.response import json_success
|
|||
from zerver.lib.subdomains import get_subdomain_from_hostname
|
||||
from zerver.lib.timestamp import convert_to_UTC, timestamp_to_datetime
|
||||
from zerver.lib.validator import to_non_negative_int
|
||||
from zerver.views.invite import get_invitee_emails_set
|
||||
|
||||
if settings.BILLING_ENABLED:
|
||||
from corporate.lib.stripe import attach_discount_to_realm, get_discount_for_realm
|
||||
|
||||
from zerver.models import (
|
||||
Client,
|
||||
MultiuseInvite,
|
||||
|
@ -72,6 +67,10 @@ from zerver.models import (
|
|||
UserProfile,
|
||||
get_realm,
|
||||
)
|
||||
from zerver.views.invite import get_invitee_emails_set
|
||||
|
||||
if settings.BILLING_ENABLED:
|
||||
from corporate.lib.stripe import attach_discount_to_realm, get_discount_for_realm
|
||||
|
||||
if settings.ZILENCER_ENABLED:
|
||||
from zilencer.models import RemoteInstallationCount, RemoteRealmCount, RemoteZulipServer
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import io
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -14,9 +16,6 @@ import django
|
|||
|
||||
django.setup()
|
||||
|
||||
import argparse
|
||||
import io
|
||||
|
||||
import cairosvg
|
||||
from PIL import Image
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ from zerver.lib.response import json_error, json_success, json_unauthorized
|
|||
from zerver.lib.subdomains import get_subdomain, user_matches_subdomain
|
||||
from zerver.lib.timestamp import datetime_to_timestamp, timestamp_to_datetime
|
||||
from zerver.lib.types import ViewFuncT
|
||||
from zerver.lib.user_agent import parse_user_agent
|
||||
from zerver.lib.utils import has_api_key_format, statsd
|
||||
from zerver.models import Realm, UserProfile, get_client, get_user_profile_by_api_key
|
||||
|
||||
|
@ -137,8 +138,6 @@ def require_billing_access(func: ViewFuncT) -> ViewFuncT:
|
|||
return func(request, user_profile, *args, **kwargs)
|
||||
return wrapper # type: ignore[return-value] # https://github.com/python/mypy/issues/1927
|
||||
|
||||
from zerver.lib.user_agent import parse_user_agent
|
||||
|
||||
|
||||
def get_client_name(request: HttpRequest) -> str:
|
||||
# If the API request specified a client in the request content,
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
import datetime
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from operator import itemgetter
|
||||
from typing import (
|
||||
AbstractSet,
|
||||
Any,
|
||||
|
@ -16,6 +24,7 @@ from typing import (
|
|||
)
|
||||
|
||||
import django.db.utils
|
||||
import ujson
|
||||
from django.conf import settings
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ValidationError
|
||||
|
@ -225,18 +234,7 @@ from zerver.models import (
|
|||
from zerver.tornado.event_queue import send_event
|
||||
|
||||
if settings.BILLING_ENABLED:
|
||||
from corporate.lib.stripe import update_license_ledger_if_needed, downgrade_now
|
||||
|
||||
import datetime
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from operator import itemgetter
|
||||
|
||||
import ujson
|
||||
from corporate.lib.stripe import downgrade_now, update_license_ledger_if_needed
|
||||
|
||||
# This will be used to type annotate parameters in a function if the function
|
||||
# works on both str and unicode in python 2 but in python 3 it only works on str.
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
import collections
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from contextlib import contextmanager
|
||||
from typing import (
|
||||
IO,
|
||||
|
@ -15,14 +20,19 @@ from typing import (
|
|||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
from unittest import mock
|
||||
|
||||
import boto3
|
||||
import fakeldap
|
||||
import ldap
|
||||
import ujson
|
||||
from boto3.resources.base import ServiceResource
|
||||
from django.conf import settings
|
||||
from django.db.migrations.state import StateApps
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.test import override_settings
|
||||
from django.urls import URLResolver
|
||||
from moto import mock_s3
|
||||
|
||||
import zerver.lib.upload
|
||||
from zerver.lib import cache
|
||||
|
@ -49,19 +59,7 @@ from zproject.backends import ExternalAuthDataDict, ExternalAuthResult
|
|||
|
||||
if TYPE_CHECKING:
|
||||
# Avoid an import cycle; we only need these for type annotations.
|
||||
from zerver.lib.test_classes import ZulipTestCase, MigrationsTestCase
|
||||
|
||||
import collections
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import fakeldap
|
||||
import ldap
|
||||
import ujson
|
||||
from moto import mock_s3
|
||||
from zerver.lib.test_classes import MigrationsTestCase, ZulipTestCase
|
||||
|
||||
|
||||
class MockLDAP(fakeldap.MockLDAP):
|
||||
|
|
|
@ -5,6 +5,8 @@ from copy import deepcopy
|
|||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from django.template.loaders import app_directories
|
||||
|
||||
import zerver.lib.logging_util
|
||||
from zerver.lib.db import TimeTrackingConnection
|
||||
|
||||
|
@ -162,8 +164,6 @@ ALLOWED_HOSTS += [EXTERNAL_HOST.split(":")[0],
|
|||
# ... and with the hosts in REALM_HOSTS.
|
||||
ALLOWED_HOSTS += REALM_HOSTS.values()
|
||||
|
||||
from django.template.loaders import app_directories
|
||||
|
||||
|
||||
class TwoFactorLoader(app_directories.Loader):
|
||||
def get_dirs(self) -> List[str]:
|
||||
|
|
Loading…
Reference in New Issue