Annotate zerver.exceptions, zerver.filters, zerver.logging_handlers.

This commit is contained in:
Tim Abbott 2016-06-04 22:51:18 -07:00
parent 33dee43179
commit 157a3efb78
3 changed files with 10 additions and 2 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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)