from __future__ import absolute_import  # Python 2 only

from django.contrib.staticfiles.storage import staticfiles_storage
from django.template.defaultfilters import slugify, pluralize
from django.core.urlresolvers import reverse
from django.template.loader import render_to_string
from django.utils import translation
from django.http import HttpResponse
from jinja2 import Environment

from .compressors import minified_js
from zerver.templatetags.app_filters import display_list, render_markdown_path


def render_to_response(*args, **kwargs):
    response = render_to_string(*args, **kwargs)
    return HttpResponse(response)


def environment(**options):
    env = Environment(**options)
    env.globals.update({
        'static': staticfiles_storage.url,
        'url': reverse,
        'minified_js': minified_js,
    })

    env.install_gettext_translations(translation, True)

    env.filters['slugify'] = slugify
    env.filters['pluralize'] = pluralize
    env.filters['display_list'] = display_list
    env.filters['render_markdown_path'] = render_markdown_path

    return env

@@ -50,16 +50,40 @@
 2 only%0A%0A
+from typing import Any%0A%0A
 from dja
@@ -561,24 +561,66 @@
  **kwargs):%0A
+    # type: (*Any, **Any) -%3E HttpResponse%0A
     response
@@ -716,24 +716,59 @@
 **options):%0A
+    # type: (**Any) -%3E Environment%0A
     env = En

Annotate jinja2/__init__.py.