diff --git a/zerver/exceptions.py b/zerver/exceptions.py index 69922ddb73..ffb837a0ab 100644 --- a/zerver/exceptions.py +++ b/zerver/exceptions.py @@ -4,4 +4,5 @@ from django.core.exceptions import PermissionDenied class RateLimited(PermissionDenied): def __init__(self, msg=""): + # type: (str) -> None super(RateLimited, self).__init__(msg) diff --git a/zerver/filters.py b/zerver/filters.py index 316c35f038..04e5a70649 100644 --- a/zerver/filters.py +++ b/zerver/filters.py @@ -1,10 +1,13 @@ from __future__ import absolute_import +from typing import Any + from django.views.debug import SafeExceptionReporterFilter -from django.http import build_request_repr +from django.http import HttpRequest, build_request_repr class ZulipExceptionReporterFilter(SafeExceptionReporterFilter): def get_post_parameters(self, request): + # type: (HttpRequest) -> Dict[str, Any] filtered_post = SafeExceptionReporterFilter.get_post_parameters(self, request).copy() filtered_vars = ['content', 'secret', 'password', 'key', 'api-key', 'subject', 'stream', 'subscriptions', 'to', 'csrfmiddlewaretoken', 'api_key'] @@ -14,6 +17,7 @@ class ZulipExceptionReporterFilter(SafeExceptionReporterFilter): filtered_post[var] = '**********' return filtered_post def get_request_repr(self, request): + # type: (HttpRequest) -> str if request is None: return repr(None) else: diff --git a/zerver/logging_handlers.py b/zerver/logging_handlers.py index ecd7cd3d0b..440ba60153 100644 --- a/zerver/logging_handlers.py +++ b/zerver/logging_handlers.py @@ -7,6 +7,7 @@ import traceback import platform 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 @@ -20,11 +21,13 @@ class AdminZulipHandler(logging.Handler): # adapted in part from django/utils/log.py def __init__(self): + # type: () -> None logging.Handler.__init__(self) def emit(self, record): + # type: (ExceptionReporter) -> None try: - request = record.request + request = record.request # type: HttpRequest filter = get_exception_reporter_filter(request)