Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 5, 2024
1 parent 8970cfd commit 9868b13
Show file tree
Hide file tree
Showing 16 changed files with 37 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/jinja2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
non-XML syntax that supports inline expressions and an optional
sandboxed environment.
"""

from .bccache import BytecodeCache as BytecodeCache
from .bccache import FileSystemBytecodeCache as FileSystemBytecodeCache
from .bccache import MemcachedBytecodeCache as MemcachedBytecodeCache
Expand Down
9 changes: 5 additions & 4 deletions src/jinja2/bccache.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Situations where this is useful are often forking web applications that
are initialized on the first request.
"""

import errno
import fnmatch
import marshal
Expand All @@ -23,11 +24,11 @@
from .environment import Environment

class _MemcachedClient(te.Protocol):
def get(self, key: str) -> bytes:
...
def get(self, key: str) -> bytes: ...

def set(self, key: str, value: bytes, timeout: t.Optional[int] = None) -> None:
...
def set(
self, key: str, value: bytes, timeout: t.Optional[int] = None
) -> None: ...


bc_version = 5
Expand Down
1 change: 1 addition & 0 deletions src/jinja2/compiler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Compiles nodes from the parser into Python code."""

import typing as t
from contextlib import contextmanager
from functools import update_wrapper
Expand Down
7 changes: 3 additions & 4 deletions src/jinja2/environment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Classes for managing templates and their runtime and compile time
options.
"""

import os
import typing
import typing as t
Expand Down Expand Up @@ -711,8 +712,7 @@ def compile( # type: ignore
filename: t.Optional[str] = None,
raw: "te.Literal[False]" = False,
defer_init: bool = False,
) -> CodeType:
...
) -> CodeType: ...

@typing.overload
def compile(
Expand All @@ -722,8 +722,7 @@ def compile(
filename: t.Optional[str] = None,
raw: "te.Literal[True]" = ...,
defer_init: bool = False,
) -> str:
...
) -> str: ...

@internalcode
def compile(
Expand Down
12 changes: 6 additions & 6 deletions src/jinja2/ext.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Extension API for adding custom tags and behavior."""

import pprint
import re
import typing as t
Expand All @@ -23,18 +24,17 @@
from .parser import Parser

class _TranslationsBasic(te.Protocol):
def gettext(self, message: str) -> str:
...
def gettext(self, message: str) -> str: ...

def ngettext(self, singular: str, plural: str, n: int) -> str:
pass

class _TranslationsContext(_TranslationsBasic):
def pgettext(self, context: str, message: str) -> str:
...
def pgettext(self, context: str, message: str) -> str: ...

def npgettext(self, context: str, singular: str, plural: str, n: int) -> str:
...
def npgettext(
self, context: str, singular: str, plural: str, n: int
) -> str: ...

_SupportedTranslations = t.Union[_TranslationsBasic, _TranslationsContext]

Expand Down
19 changes: 7 additions & 12 deletions src/jinja2/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Built-in template filters used with the ``|`` operator."""

import math
import random
import re
Expand Down Expand Up @@ -1356,13 +1357,11 @@ def do_mark_unsafe(value: str) -> str:


@typing.overload
def do_reverse(value: str) -> str:
...
def do_reverse(value: str) -> str: ...


@typing.overload
def do_reverse(value: "t.Iterable[V]") -> "t.Iterable[V]":
...
def do_reverse(value: "t.Iterable[V]") -> "t.Iterable[V]": ...


def do_reverse(value: t.Union[str, t.Iterable[V]]) -> t.Union[str, t.Iterable[V]]:
Expand Down Expand Up @@ -1417,8 +1416,7 @@ def do_attr(
@typing.overload
def sync_do_map(
context: "Context", value: t.Iterable, name: str, *args: t.Any, **kwargs: t.Any
) -> t.Iterable:
...
) -> t.Iterable: ...


@typing.overload
Expand All @@ -1428,8 +1426,7 @@ def sync_do_map(
*,
attribute: str = ...,
default: t.Optional[t.Any] = None,
) -> t.Iterable:
...
) -> t.Iterable: ...


@pass_context
Expand Down Expand Up @@ -1489,8 +1486,7 @@ def do_map(
name: str,
*args: t.Any,
**kwargs: t.Any,
) -> t.Iterable:
...
) -> t.Iterable: ...


@typing.overload
Expand All @@ -1500,8 +1496,7 @@ def do_map(
*,
attribute: str = ...,
default: t.Optional[t.Any] = None,
) -> t.Iterable:
...
) -> t.Iterable: ...


@async_variant(sync_do_map) # type: ignore
Expand Down
1 change: 1 addition & 0 deletions src/jinja2/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
the bitshift operators we don't allow in templates. It separates
template code and python code in expressions.
"""

import re
import typing as t
from ast import literal_eval
Expand Down
1 change: 1 addition & 0 deletions src/jinja2/loaders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""API and implementations for loading templates from different data
sources.
"""

import importlib.util
import os
import posixpath
Expand Down
1 change: 1 addition & 0 deletions src/jinja2/meta.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Functions that expose information about templates that might be
interesting for introspection.
"""

import typing as t

from . import nodes
Expand Down
1 change: 1 addition & 0 deletions src/jinja2/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
some node tree helper functions used by the parser and compiler in order
to normalize nodes.
"""

import inspect
import operator
import typing as t
Expand Down
1 change: 1 addition & 0 deletions src/jinja2/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
would have a different scope. The solution would be a second syntax tree
that stored the scoping rules.
"""

import typing as t

from . import nodes
Expand Down
7 changes: 3 additions & 4 deletions src/jinja2/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Parse tokens from the lexer into nodes for the compiler."""

import typing
import typing as t

Expand Down Expand Up @@ -457,8 +458,7 @@ def parse_print(self) -> nodes.Output:
@typing.overload
def parse_assign_target(
self, with_tuple: bool = ..., name_only: "te.Literal[True]" = ...
) -> nodes.Name:
...
) -> nodes.Name: ...

@typing.overload
def parse_assign_target(
Expand All @@ -467,8 +467,7 @@ def parse_assign_target(
name_only: bool = False,
extra_end_rules: t.Optional[t.Tuple[str, ...]] = None,
with_namespace: bool = False,
) -> t.Union[nodes.NSRef, nodes.Name, nodes.Tuple]:
...
) -> t.Union[nodes.NSRef, nodes.Name, nodes.Tuple]: ...

def parse_assign_target(
self,
Expand Down
4 changes: 2 additions & 2 deletions src/jinja2/runtime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The runtime functions and state used by compiled templates."""

import functools
import sys
import typing as t
Expand Down Expand Up @@ -37,8 +38,7 @@ def __call__(
reciter: t.Iterable[V],
loop_render_func: "LoopRenderFunc",
depth: int = 0,
) -> str:
...
) -> str: ...


# these variables are exported to the template runtime
Expand Down
1 change: 1 addition & 0 deletions src/jinja2/sandbox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""A sandbox layer that ensures unsafe operations cannot be performed.
Useful when the template itself comes from an untrusted source.
"""

import operator
import types
import typing as t
Expand Down
1 change: 1 addition & 0 deletions src/jinja2/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Built-in template tests used with the ``is`` operator."""

import operator
import typing as t
from collections import abc
Expand Down
4 changes: 2 additions & 2 deletions src/jinja2/visitor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""API for traversing the AST nodes. Implemented by the compiler and
meta introspection.
"""

import typing as t

from .nodes import Node
Expand All @@ -9,8 +10,7 @@
import typing_extensions as te

class VisitCallable(te.Protocol):
def __call__(self, node: Node, *args: t.Any, **kwargs: t.Any) -> t.Any:
...
def __call__(self, node: Node, *args: t.Any, **kwargs: t.Any) -> t.Any: ...


class NodeVisitor:
Expand Down

0 comments on commit 9868b13

Please sign in to comment.