mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
mypy: Migrate templatetags/minified_js.py to python3.5 annotations.
Requires introduction of full Parser & Token dependency for minified_js function annotation.
This commit is contained in:
committed by
Tim Abbott
parent
88b3abb464
commit
34db2e59dd
@@ -4,19 +4,15 @@ from django.conf import settings
|
|||||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||||
from django.template import Library, Node, TemplateSyntaxError
|
from django.template import Library, Node, TemplateSyntaxError
|
||||||
|
|
||||||
if False:
|
from django.template.base import Parser, Token
|
||||||
# no need to add dependency
|
|
||||||
from django.template.base import Parser, Token
|
|
||||||
|
|
||||||
register = Library()
|
register = Library()
|
||||||
|
|
||||||
class MinifiedJSNode(Node):
|
class MinifiedJSNode(Node):
|
||||||
def __init__(self, sourcefile):
|
def __init__(self, sourcefile: str) -> None:
|
||||||
# type: (str) -> None
|
|
||||||
self.sourcefile = sourcefile
|
self.sourcefile = sourcefile
|
||||||
|
|
||||||
def render(self, context):
|
def render(self, context: Dict[str, Any]) -> str:
|
||||||
# type: (Dict[str, Any]) -> str
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
source_files = settings.JS_SPECS[self.sourcefile]
|
source_files = settings.JS_SPECS[self.sourcefile]
|
||||||
normal_source = source_files['source_filenames']
|
normal_source = source_files['source_filenames']
|
||||||
@@ -34,8 +30,7 @@ class MinifiedJSNode(Node):
|
|||||||
|
|
||||||
|
|
||||||
@register.tag
|
@register.tag
|
||||||
def minified_js(parser, token):
|
def minified_js(parser: Parser, token: Token) -> MinifiedJSNode:
|
||||||
# type: (Parser, Token) -> MinifiedJSNode
|
|
||||||
try:
|
try:
|
||||||
tag_name, sourcefile = token.split_contents()
|
tag_name, sourcefile = token.split_contents()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
Reference in New Issue
Block a user