From f35c5d1349ad426659b8a2ca988cdcc3c48f3074 Mon Sep 17 00:00:00 2001 From: potykion Date: Thu, 28 Jun 2018 20:24:37 +0300 Subject: [PATCH] Jinja2 async support (#2278) --- third_party/2and3/jinja2/environment.pyi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/third_party/2and3/jinja2/environment.pyi b/third_party/2and3/jinja2/environment.pyi index 44508616a..8101093cb 100644 --- a/third_party/2and3/jinja2/environment.pyi +++ b/third_party/2and3/jinja2/environment.pyi @@ -1,9 +1,13 @@ +import sys from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Type, Union from .bccache import BytecodeCache from .loaders import BaseLoader from .runtime import Context, Undefined +if sys.version_info >= (3, 6): + from typing import Awaitable, AsyncIterator + def get_spontaneous_environment(*args): ... def create_cache(size): ... def copy_cache(cache): ... @@ -42,7 +46,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: Union[bool, Callable[[str], 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] = ..., enable_async: bool = ...) -> 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] = ...): ... @@ -97,6 +101,11 @@ class Template: @property def debug_info(self): ... + if sys.version_info >= (3, 6): + def render_async(self, *args, **kwargs) -> Awaitable[Text]: ... + def generate_async(self, *args, **kwargs) -> AsyncIterator[Text]: ... + + class TemplateModule: __name__ = ... # type: Any def __init__(self, template, context) -> None: ...