Annotate most Zulip management commands.

This commit is contained in:
Tim Abbott
2016-06-04 07:52:18 -07:00
parent c2bea0fa08
commit a1a27b1789
63 changed files with 321 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import absolute_import
from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from optparse import make_option
from django.core.management.base import BaseCommand
from zerver.models import get_user_profile_by_email, UserMessage
@@ -13,10 +14,12 @@ request_logger = LogRequests()
class MockSession(object):
def __init__(self):
# type: () -> None
self.modified = False
class MockRequest(object):
class MockRequest(HttpRequest):
def __init__(self, email):
# type: (str) -> None
self.user = get_user_profile_by_email(email)
self.path = '/'
self.method = "POST"
@@ -28,9 +31,11 @@ class MockRequest(object):
self.session = MockSession()
def get_full_path(self):
# type: () -> str
return self.path
def profile_request(request):
# type: (HttpRequest) -> HttpResponse
request_logger.process_request(request)
prof = cProfile.Profile()
prof.enable()
@@ -48,4 +53,5 @@ class Command(BaseCommand):
)
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
profile_request(MockRequest(options["email"]))