python: Sort imports in smaller apps.

This commit is contained in:
Tim Abbott 2017-11-15 15:55:49 -08:00
parent dc8dd2333c
commit 2b43a0302a
49 changed files with 189 additions and 210 deletions

View File

@ -1,21 +1,21 @@
import time
from collections import OrderedDict, defaultdict
from datetime import datetime, timedelta
from typing import Any, Callable, Dict, List, \
Optional, Text, Tuple, Type, Union
from django.conf import settings from django.conf import settings
from django.db import connection, models from django.db import connection, models
from django.db.models import F from django.db.models import F
from analytics.models import InstallationCount, RealmCount, \ from analytics.models import Anomaly, BaseCount, \
UserCount, StreamCount, BaseCount, FillState, Anomaly, installation_epoch, \ FillState, InstallationCount, RealmCount, StreamCount, \
last_successful_fill UserCount, installation_epoch, last_successful_fill
from zerver.models import Realm, UserProfile, Message, Stream, \
UserActivityInterval, RealmAuditLog, models
from zerver.lib.timestamp import floor_to_hour, ceiling_to_day, \
ceiling_to_hour, verify_UTC
from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Type, Union
from collections import defaultdict, OrderedDict
from datetime import timedelta, datetime
from zerver.lib.logging_util import create_logger from zerver.lib.logging_util import create_logger
import time from zerver.lib.timestamp import ceiling_to_day, \
ceiling_to_hour, floor_to_hour, verify_UTC
from zerver.models import Message, Realm, RealmAuditLog, \
Stream, UserActivityInterval, UserProfile, models
## Logging setup ## ## Logging setup ##

View File

@ -1,9 +1,9 @@
from analytics.lib.counts import CountStat
from math import sqrt from math import sqrt
from random import gauss, random, seed from random import gauss, random, seed
from typing import List from typing import List
from analytics.lib.counts import CountStat
def generate_time_series_data(days=100, business_hours_base=10, non_business_hours_base=10, def generate_time_series_data(days=100, business_hours_base=10, non_business_hours_base=10,
growth=1, autocorrelation=0, spikiness=1, holiday_rate=0, growth=1, autocorrelation=0, spikiness=1, holiday_rate=0,
frequency=CountStat.DAY, partial_sum=False, random_seed=26): frequency=CountStat.DAY, partial_sum=False, random_seed=26):

View File

@ -1,10 +1,9 @@
from zerver.lib.timestamp import floor_to_hour, floor_to_day, \
verify_UTC
from analytics.lib.counts import CountStat
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import List, Optional from typing import List, Optional
from analytics.lib.counts import CountStat
from zerver.lib.timestamp import floor_to_day, floor_to_hour, verify_UTC
# If min_length is None, returns end_times from ceiling(start) to floor(end), inclusive. # If min_length is None, returns end_times from ceiling(start) to floor(end), inclusive.
# If min_length is greater than 0, pads the list to the left. # If min_length is greater than 0, pads the list to the left.
# So informally, time_range(Sep 20, Sep 22, day, None) returns [Sep 20, Sep 21, Sep 22], # So informally, time_range(Sep 20, Sep 22, day, None) returns [Sep 20, Sep 21, Sep 22],

View File

@ -1,11 +1,12 @@
import datetime
import logging
import time
from typing import Any, Dict from typing import Any, Dict
from django.core.management.base import BaseCommand, CommandParser from django.core.management.base import BaseCommand, CommandParser
from zerver.models import Recipient, Message
from zerver.lib.timestamp import timestamp_to_datetime from zerver.lib.timestamp import timestamp_to_datetime
import datetime from zerver.models import Message, Recipient
import time
import logging
def compute_stats(log_level): def compute_stats(log_level):
# type: (int) -> None # type: (int) -> None

View File

@ -1,12 +1,12 @@
import datetime
from typing import Any, Dict from typing import Any, Dict
from zerver.lib.statistics import seconds_usage_between
from django.core.management.base import BaseCommand, CommandParser from django.core.management.base import BaseCommand, CommandParser
from zerver.models import UserProfile
import datetime
from django.utils.timezone import utc from django.utils.timezone import utc
from zerver.lib.statistics import seconds_usage_between
from zerver.models import UserProfile
def analyze_activity(options): def analyze_activity(options):
# type: (Dict[str, Any]) -> None # type: (Dict[str, Any]) -> None
day_start = datetime.datetime.strptime(options["date"], "%Y-%m-%d").replace(tzinfo=utc) day_start = datetime.datetime.strptime(options["date"], "%Y-%m-%d").replace(tzinfo=utc)

View File

@ -1,12 +1,11 @@
import sys import sys
from argparse import ArgumentParser from argparse import ArgumentParser
from typing import Any
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from analytics.lib.counts import do_drop_all_analytics_tables from analytics.lib.counts import do_drop_all_analytics_tables
from typing import Any
class Command(BaseCommand): class Command(BaseCommand):
help = """Clear analytics tables.""" help = """Clear analytics tables."""

View File

@ -1,11 +1,10 @@
import sys import sys
from argparse import ArgumentParser from argparse import ArgumentParser
from typing import Any
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from analytics.lib.counts import do_drop_single_stat, COUNT_STATS from analytics.lib.counts import COUNT_STATS, do_drop_single_stat
from typing import Any
class Command(BaseCommand): class Command(BaseCommand):
help = """Clear analytics tables.""" help = """Clear analytics tables."""

View File

@ -1,14 +1,13 @@
import datetime
from argparse import ArgumentParser
from typing import Any from typing import Any
from argparse import ArgumentParser
from django.db.models import Count, QuerySet from django.db.models import Count, QuerySet
from django.utils.timezone import now as timezone_now from django.utils.timezone import now as timezone_now
from zerver.lib.management import ZulipBaseCommand from zerver.lib.management import ZulipBaseCommand
from zerver.models import UserActivity from zerver.models import UserActivity
import datetime
class Command(ZulipBaseCommand): class Command(ZulipBaseCommand):
help = """Report rough client activity globally, for a realm, or for a user help = """Report rough client activity globally, for a realm, or for a user

View File

@ -1,19 +1,17 @@
from datetime import datetime, timedelta
from typing import Any, Dict, List, Mapping, Optional, Text, Type, Union
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.utils.timezone import now as timezone_now from django.utils.timezone import now as timezone_now
from analytics.lib.counts import COUNT_STATS, CountStat, do_drop_all_analytics_tables from analytics.lib.counts import COUNT_STATS, \
CountStat, do_drop_all_analytics_tables
from analytics.lib.fixtures import generate_time_series_data from analytics.lib.fixtures import generate_time_series_data
from analytics.lib.time_utils import time_range from analytics.lib.time_utils import time_range
from analytics.models import BaseCount, RealmCount, \ from analytics.models import BaseCount, FillState, RealmCount, UserCount
UserCount, FillState
from zerver.lib.timestamp import floor_to_day from zerver.lib.timestamp import floor_to_day
from zerver.models import Realm, UserProfile, Client, \ from zerver.models import Client, Realm, RealmAuditLog, UserProfile
RealmAuditLog
from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional, Text, Type, Union, Mapping
class Command(BaseCommand): class Command(BaseCommand):
help = """Populates analytics tables with randomly generated data.""" help = """Populates analytics tables with randomly generated data."""

View File

@ -1,15 +1,14 @@
import datetime
from argparse import ArgumentParser
from typing import Any, List from typing import Any, List
from argparse import ArgumentParser
import datetime
import pytz import pytz
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.db.models import Count from django.db.models import Count
from django.utils.timezone import now as timezone_now from django.utils.timezone import now as timezone_now
from zerver.models import UserProfile, Realm, Stream, Message, Recipient, UserActivity, \ from zerver.models import Message, Realm, Recipient, Stream, \
Subscription, UserMessage, get_realm Subscription, UserActivity, UserMessage, UserProfile, get_realm
MOBILE_CLIENT_LIST = ["Android", "ios"] MOBILE_CLIENT_LIST = ["Android", "ios"]
HUMAN_CLIENT_LIST = MOBILE_CLIENT_LIST + ["website"] HUMAN_CLIENT_LIST = MOBILE_CLIENT_LIST + ["website"]

View File

@ -1,9 +1,11 @@
from argparse import ArgumentParser
from typing import Any from typing import Any
from argparse import ArgumentParser
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.db.models import Q from django.db.models import Q
from zerver.models import Realm, Stream, Message, Subscription, Recipient, get_realm
from zerver.models import Message, Realm, \
Recipient, Stream, Subscription, get_realm
class Command(BaseCommand): class Command(BaseCommand):
help = "Generate statistics on the streams for a realm." help = "Generate statistics on the streams for a realm."

View File

@ -1,21 +1,19 @@
import os import os
from scripts.lib.zulip_tools import ENDC, WARNING
from argparse import ArgumentParser
import time import time
from argparse import ArgumentParser
from typing import Any, Dict
from django.conf import settings
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.utils.dateparse import parse_datetime
from django.utils.timezone import now as timezone_now from django.utils.timezone import now as timezone_now
from django.utils.timezone import utc as timezone_utc from django.utils.timezone import utc as timezone_utc
from django.utils.dateparse import parse_datetime
from django.conf import settings
from analytics.lib.counts import COUNT_STATS, logger, process_count_stat from analytics.lib.counts import COUNT_STATS, logger, process_count_stat
from scripts.lib.zulip_tools import ENDC, WARNING
from zerver.lib.timestamp import floor_to_hour from zerver.lib.timestamp import floor_to_hour
from zerver.models import Realm from zerver.models import Realm
from typing import Any, Dict
class Command(BaseCommand): class Command(BaseCommand):
help = """Fills Analytics tables. help = """Fills Analytics tables.

View File

@ -1,11 +1,11 @@
from argparse import ArgumentParser
import datetime import datetime
from argparse import ArgumentParser
from typing import Any from typing import Any
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.utils.timezone import now as timezone_now from django.utils.timezone import now as timezone_now
from zerver.models import UserProfile, Realm, Stream, Message, get_realm from zerver.models import Message, Realm, Stream, UserProfile, get_realm
class Command(BaseCommand): class Command(BaseCommand):
help = "Generate statistics on user activity." help = "Generate statistics on user activity."

View File

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import models, migrations
import django.db.models.deletion import django.db.models.deletion
from django.conf import settings from django.conf import settings
import zerver.lib.str_utils from django.db import migrations, models
import zerver.lib.str_utils
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import migrations, models from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import migrations, models from django.db import migrations, models
import zerver.lib.str_utils
import zerver.lib.str_utils
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import migrations, models from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import migrations, models from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import migrations, models from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View File

@ -3,7 +3,6 @@
from django.conf import settings from django.conf import settings
from django.db import migrations from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View File

@ -2,7 +2,6 @@
# Generated by Django 1.10.5 on 2017-02-01 22:28 # Generated by Django 1.10.5 on 2017-02-01 22:28
from django.db import migrations from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View File

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps from django.db.migrations.state import StateApps
from django.db import migrations
def delete_messages_sent_to_stream_stat(apps, schema_editor): def delete_messages_sent_to_stream_stat(apps, schema_editor):
# type: (StateApps, DatabaseSchemaEditor) -> None # type: (StateApps, DatabaseSchemaEditor) -> None

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps from django.db.migrations.state import StateApps
from django.db import migrations
def clear_message_sent_by_message_type_values(apps, schema_editor): def clear_message_sent_by_message_type_values(apps, schema_editor):
# type: (StateApps, DatabaseSchemaEditor) -> None # type: (StateApps, DatabaseSchemaEditor) -> None

View File

@ -1,8 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps from django.db.migrations.state import StateApps
from django.db import migrations
def clear_analytics_tables(apps, schema_editor): def clear_analytics_tables(apps, schema_editor):
# type: (StateApps, DatabaseSchemaEditor) -> None # type: (StateApps, DatabaseSchemaEditor) -> None

View File

@ -1,11 +1,10 @@
import datetime
from typing import Any, Dict, Optional, Text, Tuple, Union
from django.db import models from django.db import models
from zerver.models import Realm, UserProfile, Stream, Recipient
from zerver.lib.timestamp import floor_to_day from zerver.lib.timestamp import floor_to_day
from zerver.models import Realm, Recipient, Stream, UserProfile
import datetime
from typing import Optional, Tuple, Union, Dict, Any, Text
class FillState(models.Model): class FillState(models.Model):
property = models.CharField(max_length=40, unique=True) # type: Text property = models.CharField(max_length=40, unique=True) # type: Text

View File

@ -1,4 +1,8 @@
from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional, Text, Tuple, Type, Union
import ujson
from django.apps import apps from django.apps import apps
from django.db import models from django.db import models
from django.db.models import Sum from django.db.models import Sum
@ -6,23 +10,20 @@ from django.test import TestCase
from django.utils.timezone import now as timezone_now from django.utils.timezone import now as timezone_now
from django.utils.timezone import utc as timezone_utc from django.utils.timezone import utc as timezone_utc
from analytics.lib.counts import CountStat, COUNT_STATS, process_count_stat, \ from analytics.lib.counts import COUNT_STATS, CountStat, DataCollector, \
do_fill_count_stat_at_hour, do_increment_logging_stat, DataCollector, \ DependentCountStat, LoggingCountStat, do_aggregate_to_summary_table, \
sql_data_collector, LoggingCountStat, do_aggregate_to_summary_table, \ do_drop_all_analytics_tables, do_drop_single_stat, \
do_drop_all_analytics_tables, do_drop_single_stat, DependentCountStat do_fill_count_stat_at_hour, do_increment_logging_stat, \
from analytics.models import BaseCount, InstallationCount, RealmCount, \ process_count_stat, sql_data_collector
UserCount, StreamCount, FillState, Anomaly, installation_epoch, \ from analytics.models import Anomaly, BaseCount, \
last_successful_fill FillState, InstallationCount, RealmCount, StreamCount, \
from zerver.lib.actions import do_create_user, do_deactivate_user, \ UserCount, installation_epoch, last_successful_fill
do_activate_user, do_reactivate_user, update_user_activity_interval from zerver.lib.actions import do_activate_user, do_create_user, \
from zerver.lib.timestamp import floor_to_day, TimezoneNotUTCException do_deactivate_user, do_reactivate_user, update_user_activity_interval
from zerver.models import Realm, UserProfile, Message, Stream, Recipient, \ from zerver.lib.timestamp import TimezoneNotUTCException, floor_to_day
Huddle, Client, UserActivityInterval, RealmAuditLog, get_client, get_user from zerver.models import Client, Huddle, Message, Realm, \
RealmAuditLog, Recipient, Stream, UserActivityInterval, \
from datetime import datetime, timedelta UserProfile, get_client, get_user
import ujson
from typing import Any, Dict, List, Optional, Text, Tuple, Type, Union
class AnalyticsTestCase(TestCase): class AnalyticsTestCase(TestCase):
MINUTE = timedelta(seconds = 60) MINUTE = timedelta(seconds = 60)

View File

@ -1,7 +1,6 @@
from zerver.lib.test_classes import ZulipTestCase
from analytics.lib.counts import CountStat from analytics.lib.counts import CountStat
from analytics.lib.fixtures import generate_time_series_data from analytics.lib.fixtures import generate_time_series_data
from zerver.lib.test_classes import ZulipTestCase
# A very light test suite; the code being tested is not run in production. # A very light test suite; the code being tested is not run in production.
class TestFixtures(ZulipTestCase): class TestFixtures(ZulipTestCase):

View File

@ -1,20 +1,19 @@
from django.utils.timezone import utc
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import ceiling_to_hour, ceiling_to_day, \
datetime_to_timestamp
from zerver.models import Client, get_realm
from analytics.lib.counts import CountStat, COUNT_STATS
from analytics.lib.time_utils import time_range
from analytics.models import RealmCount, UserCount, \
FillState, last_successful_fill
from analytics.views import stats, get_chart_data, sort_by_totals, \
sort_client_labels, rewrite_client_arrays
from datetime import datetime, timedelta from datetime import datetime, timedelta
import mock from typing import Dict, List, Optional
from typing import List, Dict, Optional import mock
from django.utils.timezone import utc
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 zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import ceiling_to_day, \
ceiling_to_hour, datetime_to_timestamp
from zerver.models import Client, get_realm
class TestStatsEndpoint(ZulipTestCase): class TestStatsEndpoint(ZulipTestCase):
def test_stats(self): def test_stats(self):

View File

@ -1,7 +1,7 @@
from django.conf.urls import url, include from django.conf.urls import include, url
from zerver.lib.rest import rest_dispatch
import analytics.views import analytics.views
from zerver.lib.rest import rest_dispatch
i18n_urlpatterns = [ i18n_urlpatterns = [
# Server admin (user_profile.is_staff) visible stats pages # Server admin (user_profile.is_staff) visible stats pages

View File

@ -1,42 +1,40 @@
import itertools
import json
import logging
import re
import time
from collections import defaultdict
from datetime import datetime, timedelta
from typing import Any, Callable, Dict, List, \
Optional, Set, Text, Tuple, Type, Union
import pytz
from django.conf import settings from django.conf import settings
from django.core import urlresolvers from django.core import urlresolvers
from django.db import connection from django.db import connection
from django.db.models import Sum from django.db.models import Sum
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django.http import HttpResponseNotFound, HttpRequest, HttpResponse from django.http import HttpRequest, HttpResponse, HttpResponseNotFound
from django.shortcuts import render
from django.template import RequestContext, loader from django.template import RequestContext, loader
from django.utils.timezone import now as timezone_now from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.shortcuts import render
from jinja2 import Markup as mark_safe from jinja2 import Markup as mark_safe
from analytics.lib.counts import CountStat, process_count_stat, COUNT_STATS from analytics.lib.counts import COUNT_STATS, CountStat, process_count_stat
from analytics.lib.time_utils import time_range from analytics.lib.time_utils import time_range
from analytics.models import BaseCount, InstallationCount, RealmCount, \ from analytics.models import BaseCount, InstallationCount, \
UserCount, StreamCount, last_successful_fill RealmCount, StreamCount, UserCount, last_successful_fill
from zerver.decorator import require_server_admin, \
from zerver.decorator import require_server_admin, zulip_login_required, \ to_non_negative_int, to_utc_datetime, zulip_login_required
to_non_negative_int, to_utc_datetime
from zerver.lib.exceptions import JsonableError from zerver.lib.exceptions import JsonableError
from zerver.lib.request import has_request_variables, REQ from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success from zerver.lib.response import json_success
from zerver.lib.timestamp import ceiling_to_hour, ceiling_to_day, \ from zerver.lib.timestamp import ceiling_to_day, \
timestamp_to_datetime, convert_to_UTC ceiling_to_hour, convert_to_UTC, timestamp_to_datetime
from zerver.models import Realm, UserProfile, UserActivity, \ from zerver.models import Client, Realm, \
UserActivityInterval, Client UserActivity, UserActivityInterval, UserProfile
from collections import defaultdict
from datetime import datetime, timedelta
import itertools
import json
import logging
import pytz
import re
import time
from typing import Any, Callable, Dict, List, Optional, Set, Text, \
Tuple, Type, Union
@zulip_login_required @zulip_login_required
def stats(request): def stats(request):

View File

@ -1,14 +1,15 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand
from zerver.lib.actions import create_stream_if_needed, \
internal_prep_stream_message, do_create_user, do_send_messages, \
do_add_reaction_legacy, bulk_add_subscriptions, do_change_avatar_fields
from zerver.lib.upload import upload_avatar_image
from zerver.models import get_realm, UserProfile, Message
from typing import Any, Dict, List from typing import Any, Dict, List
from django.core.management.base import BaseCommand
from zerver.lib.actions import bulk_add_subscriptions, \
create_stream_if_needed, do_add_reaction_legacy, do_change_avatar_fields, \
do_create_user, do_send_messages, internal_prep_stream_message
from zerver.lib.upload import upload_avatar_image
from zerver.models import Message, UserProfile, get_realm
class Command(BaseCommand): class Command(BaseCommand):
help = """Add a mock conversation to the development environment. help = """Add a mock conversation to the development environment.

View File

@ -1,11 +1,11 @@
from zerver.lib.actions import do_create_user, do_create_realm
from zerver.lib.management import ZulipBaseCommand
from zerver.lib.onboarding import setup_initial_streams, \
setup_initial_private_stream, send_initial_realm_messages
from zerver.models import Realm, UserProfile
from typing import Any from typing import Any
from zerver.lib.actions import do_create_realm, do_create_user
from zerver.lib.management import ZulipBaseCommand
from zerver.lib.onboarding import send_initial_realm_messages, \
setup_initial_private_stream, setup_initial_streams
from zerver.models import Realm, UserProfile
class Command(ZulipBaseCommand): class Command(ZulipBaseCommand):
help = """Add a new realm and initial user for manual testing of the onboarding process.""" help = """Add a new realm and initial user for manual testing of the onboarding process."""

View File

@ -1,10 +1,11 @@
from typing import Any
from django.core.management.base import CommandParser from django.core.management.base import CommandParser
from zerver.lib.actions import do_create_user from zerver.lib.actions import do_create_user
from zerver.lib.management import ZulipBaseCommand from zerver.lib.management import ZulipBaseCommand
from zerver.models import Realm, UserProfile from zerver.models import Realm, UserProfile
from typing import Any
class Command(ZulipBaseCommand): class Command(ZulipBaseCommand):
help = """Add a new user for manual testing of the onboarding process. help = """Add a new user for manual testing of the onboarding process.
If realm is unspecified, will try to use a realm created by add_new_realm, If realm is unspecified, will try to use a realm created by add_new_realm,

View File

@ -1,10 +1,8 @@
from typing import Any from typing import Any
import ijson import ijson
from django.core.management.base import BaseCommand, CommandParser from django.core.management.base import BaseCommand, CommandParser
class Command(BaseCommand): class Command(BaseCommand):
help = """ help = """
Render messages to a file. Render messages to a file.

View File

@ -2,10 +2,11 @@
from typing import Any from typing import Any
from django.conf import settings from django.conf import settings
from django.core.cache import cache
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.db.models import F from django.db.models import F
from django.core.cache import cache
from zerver.models import UserProfile, UserMessage from zerver.models import UserMessage, UserProfile
class Command(BaseCommand): class Command(BaseCommand):
help = """Script to mark all messages as unread.""" help = """Script to mark all messages as unread."""

View File

@ -2,6 +2,7 @@
from typing import Any from typing import Any
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from zerver.models import Subscription from zerver.models import Subscription
class Command(BaseCommand): class Command(BaseCommand):

View File

@ -1,27 +1,26 @@
from django.core.management.base import BaseCommand, CommandParser import itertools
from django.utils.timezone import now as timezone_now import os
from django.db.models import F, Max import random
from typing import Any, Callable, Dict, Iterable, List, \
Mapping, Optional, Sequence, Set, Text, Tuple
from zerver.models import Message, UserProfile, Stream, Recipient, UserPresence, \ import ujson
Subscription, RealmAuditLog, get_huddle, Realm, RealmEmoji, UserMessage, \
RealmDomain, clear_database, get_client, get_user_profile_by_id, \
email_to_username, Service, get_user, DefaultStream, get_stream, \
get_realm, get_system_bot
from zerver.lib.actions import STREAM_ASSIGNMENT_COLORS, do_send_messages, \
do_change_is_admin
from django.conf import settings from django.conf import settings
from django.core.management.base import BaseCommand, CommandParser
from django.db.models import F, Max
from django.utils.timezone import now as timezone_now
from zerver.lib.actions import STREAM_ASSIGNMENT_COLORS, \
do_change_is_admin, do_send_messages
from zerver.lib.bulk_create import bulk_create_streams, bulk_create_users from zerver.lib.bulk_create import bulk_create_streams, bulk_create_users
from zerver.lib.generate_test_data import create_test_data from zerver.lib.generate_test_data import create_test_data
from zerver.lib.upload import upload_backend from zerver.lib.upload import upload_backend
from zerver.lib.user_groups import create_user_group from zerver.lib.user_groups import create_user_group
from zerver.models import DefaultStream, Message, Realm, RealmAuditLog, \
RealmDomain, RealmEmoji, Recipient, Service, Stream, Subscription, \
import random UserMessage, UserPresence, UserProfile, clear_database, \
import os email_to_username, get_client, get_huddle, get_realm, get_stream, \
import ujson get_system_bot, get_user, get_user_profile_by_id
import itertools
from typing import Any, Callable, Dict, List, Iterable, Mapping, Optional, Sequence, Set, Tuple, Text
settings.TORNADO_SERVER = None settings.TORNADO_SERVER = None
# Disable using memcached caches to avoid 'unsupported pickle # Disable using memcached caches to avoid 'unsupported pickle

View File

@ -1,6 +1,6 @@
from argparse import ArgumentParser
from typing import Any from typing import Any
from argparse import ArgumentParser
from zerver.lib.initial_password import initial_password from zerver.lib.initial_password import initial_password
from zerver.lib.management import ZulipBaseCommand from zerver.lib.management import ZulipBaseCommand

View File

@ -1,13 +1,14 @@
from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from django.core.management.base import CommandParser
from zerver.lib.management import ZulipBaseCommand
from zerver.models import UserMessage, UserProfile
from zerver.views.messages import get_messages_backend
import cProfile import cProfile
import logging import logging
from typing import Any, Dict
from django.core.management.base import CommandParser
from django.http import HttpRequest, HttpResponse
from zerver.lib.management import ZulipBaseCommand
from zerver.middleware import LogRequests from zerver.middleware import LogRequests
from zerver.models import UserMessage, UserProfile
from zerver.views.messages import get_messages_backend
request_logger = LogRequests() request_logger = LogRequests()

View File

@ -1,14 +1,13 @@
import os import os
import ujson
from typing import Any, Iterator from typing import Any, Iterator
import ujson
from django.core.management.base import BaseCommand, CommandParser from django.core.management.base import BaseCommand, CommandParser
from django.db.models import QuerySet from django.db.models import QuerySet
from zerver.lib.message import render_markdown from zerver.lib.message import render_markdown
from zerver.models import Message from zerver.models import Message
def queryset_iterator(queryset, chunksize=5000): def queryset_iterator(queryset, chunksize=5000):
# type: (QuerySet, int) -> Iterator[Any] # type: (QuerySet, int) -> Iterator[Any]
queryset = queryset.order_by('id') queryset = queryset.order_by('id')

View File

@ -1,9 +1,10 @@
import os
from configparser import ConfigParser
from typing import Any from typing import Any
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from zerver.models import get_realm, get_user, UserProfile
import os from zerver.models import UserProfile, get_realm, get_user
from configparser import ConfigParser
class Command(BaseCommand): class Command(BaseCommand):
help = """Sync your API key from ~/.zuliprc into your development instance""" help = """Sync your API key from ~/.zuliprc into your development instance"""

View File

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import models, migrations from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,7 +2,6 @@
# Generated by Django 1.10.5 on 2017-05-16 00:03 # Generated by Django 1.10.5 on 2017-05-16 00:03
from django.db import migrations, models from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View File

@ -2,7 +2,6 @@
# Generated by Django 1.11.5 on 2017-10-12 06:27 # Generated by Django 1.11.5 on 2017-10-12 06:27
from django.db import migrations from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View File

@ -4,7 +4,6 @@ from __future__ import unicode_literals
from django.db import migrations, models from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [

View File

@ -1,8 +1,9 @@
from django.db import models import datetime
from typing import Text from typing import Text
from django.db import models
import zerver.models import zerver.models
import datetime
def get_remote_server_by_uuid(uuid): def get_remote_server_by_uuid(uuid):
# type: (Text) -> RemoteZulipServer # type: (Text) -> RemoteZulipServer

View File

@ -1,9 +1,9 @@
from django.conf.urls import url, include
from typing import Any from typing import Any
from zerver.lib.rest import rest_dispatch from django.conf.urls import include, url
import zilencer.views import zilencer.views
from zerver.lib.rest import rest_dispatch
i18n_urlpatterns = [] # type: Any i18n_urlpatterns = [] # type: Any

View File

@ -1,20 +1,19 @@
from django.utils.translation import ugettext as _ from typing import Any, Dict, Optional, Text, Union, cast
from django.http import HttpRequest, HttpResponse
from django.utils import timezone from django.utils import timezone
from django.http import HttpResponse, HttpRequest from django.utils.translation import ugettext as _
from zilencer.models import RemotePushDeviceToken, RemoteZulipServer
from zerver.lib.exceptions import JsonableError from zerver.lib.exceptions import JsonableError
from zerver.lib.push_notifications import send_android_push_notification, \ from zerver.lib.push_notifications import send_android_push_notification, \
send_apple_push_notification send_apple_push_notification
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_error, json_success from zerver.lib.response import json_error, json_success
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.validator import check_int from zerver.lib.validator import check_int
from zerver.models import UserProfile from zerver.models import UserProfile
from zerver.views.push_notifications import validate_token from zerver.views.push_notifications import validate_token
from zilencer.models import RemotePushDeviceToken, RemoteZulipServer
from typing import Any, Dict, Optional, Union, Text, cast
def validate_entity(entity): def validate_entity(entity):
# type: (Union[UserProfile, RemoteZulipServer]) -> None # type: (Union[UserProfile, RemoteZulipServer]) -> None