zproject: Use python 3 syntax for typing.

This commit is contained in:
rht 2017-10-27 13:03:15 +02:00 committed by Tim Abbott
parent 77f32a1e0c
commit 26b6b893e6
5 changed files with 6 additions and 12 deletions

View File

@ -8,8 +8,7 @@ from django.core.mail import EmailMultiAlternatives
from django.template import loader from django.template import loader
class EmailLogBackEnd(BaseEmailBackend): class EmailLogBackEnd(BaseEmailBackend):
def log_email(self, email): def log_email(self, email: EmailMultiAlternatives) -> None:
# type: (EmailMultiAlternatives) -> None
"""Used in development to record sent emails in a nice HTML log""" """Used in development to record sent emails in a nice HTML log"""
html_message = 'Missing HTML message' html_message = 'Missing HTML message'
if len(email.alternatives) > 0: if len(email.alternatives) > 0:
@ -36,8 +35,7 @@ class EmailLogBackEnd(BaseEmailBackend):
with open(settings.EMAIL_CONTENT_LOG_PATH, "w+") as f: with open(settings.EMAIL_CONTENT_LOG_PATH, "w+") as f:
f.write(new_email + previous_emails) f.write(new_email + previous_emails)
def send_messages(self, email_messages): def send_messages(self, email_messages: List[EmailMultiAlternatives]) -> int:
# type: (List[EmailMultiAlternatives]) -> int
for email in email_messages: for email in email_messages:
self.log_email(email) self.log_email(email)
email_log_url = settings.ROOT_DOMAIN_URI + "/emails" email_log_url = settings.ROOT_DOMAIN_URI + "/emails"

View File

@ -13,8 +13,7 @@ from .compressors import minified_js
from zerver.templatetags.app_filters import display_list, render_markdown_path from zerver.templatetags.app_filters import display_list, render_markdown_path
def environment(**options): def environment(**options: Any) -> Environment:
# type: (**Any) -> Environment
env = Environment(**options) env = Environment(**options)
env.globals.update({ env.globals.update({
'static': staticfiles_storage.url, 'static': staticfiles_storage.url,

View File

@ -10,8 +10,7 @@ from django.template import TemplateSyntaxError
from zerver.templatetags.minified_js import MinifiedJSNode from zerver.templatetags.minified_js import MinifiedJSNode
def minified_js(sourcefile): def minified_js(sourcefile: str) -> Text:
# type: (str) -> Text
if sourcefile not in settings.JS_SPECS: if sourcefile not in settings.JS_SPECS:
raise TemplateSyntaxError( raise TemplateSyntaxError(
"Invalid argument: no JS file %s".format(sourcefile)) "Invalid argument: no JS file %s".format(sourcefile))

View File

@ -39,8 +39,7 @@ if PRODUCTION:
else: else:
secrets_file.read(os.path.join(DEPLOY_ROOT, "zproject/dev-secrets.conf")) secrets_file.read(os.path.join(DEPLOY_ROOT, "zproject/dev-secrets.conf"))
def get_secret(key): def get_secret(key: str) -> None:
# type: (str) -> None
if secrets_file.has_option('secrets', key): if secrets_file.has_option('secrets', key):
return secrets_file.get('secrets', key) return secrets_file.get('secrets', key)
return None return None

View File

@ -560,8 +560,7 @@ if settings.DEVELOPMENT:
# tests to fail # tests to fail
urlpatterns = i18n_patterns(*i18n_urls) + urls + legacy_urls urlpatterns = i18n_patterns(*i18n_urls) + urls + legacy_urls
def handler400(request, exception): def handler400(request: HttpRequest, exception: Exception) -> HttpResponse:
# type: (HttpRequest, Exception) -> HttpResponse
# #
# This behaves exactly like the default Django implementation in # This behaves exactly like the default Django implementation in
# the case where you haven't made a template "400.html", which we # the case where you haven't made a template "400.html", which we