diff --git a/third_party/2and3/jinja2/utils.pyi b/third_party/2and3/jinja2/utils.pyi index bf5ff8356..c588ce8b3 100644 --- a/third_party/2and3/jinja2/utils.pyi +++ b/third_party/2and3/jinja2/utils.pyi @@ -1,4 +1,5 @@ -from typing import Any, Callable, Iterable, Optional +import sys +from typing import Any, Callable, IO, Iterable, Optional, Protocol, Text, TypeVar, Union from markupsafe import Markup as Markup, escape as escape, soft_unicode as soft_unicode @@ -6,21 +7,47 @@ missing: Any internal_code: Any concat: Any -def contextfunction(f): ... -def evalcontextfunction(f): ... -def environmentfunction(f): ... -def internalcode(f): ... -def is_undefined(obj): ... +if sys.version_info >= (3, 8): + from typing import Literal + _True = Literal[True] +else: + _True = bool + +if sys.version_info >= (3, 6): + from builtins import _PathLike + _PathType = Union[bytes, Text, _PathLike] +else: + _PathType = Union[bytes, Text] + +_CallableT = TypeVar("_CallableT", bound=Callable[..., Any]) + +class _ContextFunction(Protocol[_CallableT]): + contextfunction: _True + __call__: _CallableT + +class _EvalContextFunction(Protocol[_CallableT]): + evalcontextfunction: _True + __call__: _CallableT + +class _EnvironmentFunction(Protocol[_CallableT]): + environmentfunction: _True + __call__: _CallableT + +def contextfunction(f: _CallableT) -> _ContextFunction[_CallableT]: ... +def evalcontextfunction(f: _CallableT) -> _EvalContextFunction[_CallableT]: ... +def environmentfunction(f: _CallableT) -> _EnvironmentFunction[_CallableT]: ... +def internalcode(f: _CallableT) -> _CallableT: ... +def is_undefined(obj: object) -> bool: ... 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 = ...): ... -def open_if_exists(filename, mode: str = ...): ... -def object_type_repr(obj): ... -def pformat(obj, verbose: bool = ...): ... -def urlize(text, trim_url_limit: Optional[Any] = ..., nofollow: bool = ..., target: Optional[Any] = ...): ... -def generate_lorem_ipsum(n: int = ..., html: bool = ..., min: int = ..., max: int = ...): ... -def unicode_urlencode(obj, charset: str = ..., for_qs: bool = ...): ... +def consume(iterable: Iterable[object]) -> None: ... +def clear_caches() -> None: ... +def import_string(import_name: str, silent: bool = ...) -> Any: ... +def open_if_exists(filename: _PathType, mode: str = ...) -> Optional[IO[Any]]: ... +def object_type_repr(obj: object) -> str: ... +def pformat(obj: object, verbose: bool = ...) -> str: ... +def urlize(text: Union[Markup, Text], trim_url_limit: Optional[int] = ..., rel: Optional[Union[Markup, Text]] = ..., target: Optional[Union[Markup, Text]] = ...) -> str: ... +def generate_lorem_ipsum(n: int = ..., html: bool = ..., min: int = ..., max: int = ...) -> Union[Markup, str]: ... +def unicode_urlencode(obj: object, charset: str = ..., for_qs: bool = ...) -> str: ... class LRUCache: capacity: Any