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