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
class EmailLogBackEnd(BaseEmailBackend):
def log_email(self, email):
# type: (EmailMultiAlternatives) -> None
def log_email(self, email: EmailMultiAlternatives) -> None:
"""Used in development to record sent emails in a nice HTML log"""
html_message = 'Missing HTML message'
if len(email.alternatives) > 0:
@ -36,8 +35,7 @@ class EmailLogBackEnd(BaseEmailBackend):
with open(settings.EMAIL_CONTENT_LOG_PATH, "w+") as f:
f.write(new_email + previous_emails)
def send_messages(self, email_messages):
# type: (List[EmailMultiAlternatives]) -> int
def send_messages(self, email_messages: List[EmailMultiAlternatives]) -> int:
for email in email_messages:
self.log_email(email)
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
def environment(**options):
# type: (**Any) -> Environment
def environment(**options: Any) -> Environment:
env = Environment(**options)
env.globals.update({
'static': staticfiles_storage.url,

View File

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

View File

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

View File

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