From 6031b37be957104a115ecf5f31f29a12ff87adde Mon Sep 17 00:00:00 2001 From: Zack Hsi Date: Mon, 7 Aug 2017 16:19:45 -0700 Subject: [PATCH] Add select_autoescape to jinja2 (#1530) Fixes https://github.com/python/mypy/issues/3589. --- third_party/2and3/jinja2/__init__.pyi | 2 +- third_party/2and3/jinja2/environment.pyi | 2 +- third_party/2and3/jinja2/utils.pyi | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/third_party/2and3/jinja2/__init__.pyi b/third_party/2and3/jinja2/__init__.pyi index 96a5249d3..063f73d8d 100644 --- a/third_party/2and3/jinja2/__init__.pyi +++ b/third_party/2and3/jinja2/__init__.pyi @@ -4,4 +4,4 @@ from jinja2.bccache import BytecodeCache as BytecodeCache, FileSystemBytecodeCac from jinja2.runtime import Undefined as Undefined, DebugUndefined as DebugUndefined, StrictUndefined as StrictUndefined, make_logging_undefined as make_logging_undefined from jinja2.exceptions import TemplateError as TemplateError, UndefinedError as UndefinedError, TemplateNotFound as TemplateNotFound, TemplatesNotFound as TemplatesNotFound, TemplateSyntaxError as TemplateSyntaxError, TemplateAssertionError as TemplateAssertionError from jinja2.filters import environmentfilter as environmentfilter, contextfilter as contextfilter, evalcontextfilter as evalcontextfilter -from jinja2.utils import Markup as Markup, escape as escape, clear_caches as clear_caches, environmentfunction as environmentfunction, evalcontextfunction as evalcontextfunction, contextfunction as contextfunction, is_undefined as is_undefined +from jinja2.utils import Markup as Markup, escape as escape, clear_caches as clear_caches, environmentfunction as environmentfunction, evalcontextfunction as evalcontextfunction, contextfunction as contextfunction, is_undefined as is_undefined, select_autoescape as select_autoescape diff --git a/third_party/2and3/jinja2/environment.pyi b/third_party/2and3/jinja2/environment.pyi index 5c5865163..909211ca8 100644 --- a/third_party/2and3/jinja2/environment.pyi +++ b/third_party/2and3/jinja2/environment.pyi @@ -42,7 +42,7 @@ class Environment: bytecode_cache = ... # type: BytecodeCache auto_reload = ... # type: bool extensions = ... # type: List - def __init__(self, block_start_string: Text = ..., block_end_string: Text = ..., variable_start_string: Text = ..., variable_end_string: Text = ..., comment_start_string: Any = ..., comment_end_string: Text = ..., line_statement_prefix: Text = ..., line_comment_prefix: Text = ..., trim_blocks: bool = ..., lstrip_blocks: bool = ..., newline_sequence: Text = ..., keep_trailing_newline: bool = ..., extensions: List = ..., optimized: bool = ..., undefined: Type[Undefined] = ..., finalize: Optional[Callable] = ..., autoescape: bool = ..., loader: Optional[BaseLoader] = ..., cache_size: int = ..., auto_reload: bool = ..., bytecode_cache: Optional[BytecodeCache] = ...) -> None: ... + def __init__(self, block_start_string: Text = ..., block_end_string: Text = ..., variable_start_string: Text = ..., variable_end_string: Text = ..., comment_start_string: Any = ..., comment_end_string: Text = ..., line_statement_prefix: Text = ..., line_comment_prefix: Text = ..., trim_blocks: bool = ..., lstrip_blocks: bool = ..., newline_sequence: Text = ..., keep_trailing_newline: bool = ..., extensions: List = ..., optimized: bool = ..., undefined: Type[Undefined] = ..., finalize: Optional[Callable] = ..., autoescape: Union[bool, Callable[[str], bool]] = ..., loader: Optional[BaseLoader] = ..., cache_size: int = ..., auto_reload: bool = ..., bytecode_cache: Optional[BytecodeCache] = ...) -> None: ... def add_extension(self, extension): ... def extend(self, **attributes): ... def overlay(self, block_start_string: Text = ..., block_end_string: Text = ..., variable_start_string: Text = ..., variable_end_string: Text = ..., comment_start_string: Any = ..., comment_end_string: Text = ..., line_statement_prefix: Text = ..., line_comment_prefix: Text = ..., trim_blocks: bool = ..., lstrip_blocks: bool = ..., extensions: List = ..., optimized: bool = ..., undefined: Type[Undefined] = ..., finalize: Callable = ..., autoescape: bool = ..., loader: Optional[BaseLoader] = ..., cache_size: int = ..., auto_reload: bool = ..., bytecode_cache: Optional[BytecodeCache] = ...): ... diff --git a/third_party/2and3/jinja2/utils.pyi b/third_party/2and3/jinja2/utils.pyi index 7cff2cc98..196bab32c 100644 --- a/third_party/2and3/jinja2/utils.pyi +++ b/third_party/2and3/jinja2/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any, Callable, Iterable, Optional from markupsafe import Markup as Markup, escape as escape, soft_unicode as soft_unicode @@ -11,6 +11,7 @@ def evalcontextfunction(f): ... def environmentfunction(f): ... def internalcode(f): ... def is_undefined(obj): ... +def select_autoescape(enabled_extensions: Iterable[str] = ..., disabled_extensions: Iterable[str] = ..., default_for_string: bool = ..., default: bool = ...) -> Callable[[str], bool]: ... def consume(iterable): ... def clear_caches(): ... def import_string(import_name, silent: bool = ...): ...