]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
apply ruff fixes
authorDavid Lord <davidism@gmail.com>
Fri, 23 Aug 2024 23:49:44 +0000 (16:49 -0700)
committerDavid Lord <davidism@gmail.com>
Fri, 23 Aug 2024 23:49:44 +0000 (16:49 -0700)
pyproject.toml
src/jinja2/async_utils.py
src/jinja2/debug.py
src/jinja2/environment.py
src/jinja2/filters.py
src/jinja2/idtracking.py
src/jinja2/lexer.py
src/jinja2/parser.py
src/jinja2/runtime.py
src/jinja2/sandbox.py
src/jinja2/utils.py

index 5de076b1733d6c0a2e60ecc65fc4b0d0d7bc89e8..a7cfa7f93d534924f051bdcdaec5f36871feb22c 100644 (file)
@@ -91,7 +91,6 @@ select = [
     "UP",  # pyupgrade
     "W",  # pycodestyle warning
 ]
-ignore-init-module-imports = true
 
 [tool.ruff.lint.isort]
 force-single-line = true
index b0d277de7767e4d874f8873f3a07c3203c791017..f0c140205c50a3df9863ce1ab610b0c62a483f1b 100644 (file)
@@ -67,7 +67,7 @@ async def auto_await(value: t.Union[t.Awaitable["V"], "V"]) -> "V":
     if inspect.isawaitable(value):
         return await t.cast("t.Awaitable[V]", value)
 
-    return t.cast("V", value)
+    return value
 
 
 class _IteratorToAsyncIterator(t.Generic[V]):
index 7ed7e9297e01b87c4e999d19d48a4265b38b574f..eeeeee78b620f5d0745133b4629647973cd7af87 100644 (file)
@@ -152,7 +152,7 @@ def get_template_locals(real_locals: t.Mapping[str, t.Any]) -> t.Dict[str, t.Any
     available at that point in the template.
     """
     # Start with the current template context.
-    ctx: "t.Optional[Context]" = real_locals.get("context")
+    ctx: t.Optional[Context] = real_locals.get("context")
 
     if ctx is not None:
         data: t.Dict[str, t.Any] = ctx.get_all().copy()
index 57a7f89664d454ebfc86afef08168dba1a3616eb..f062e40740d44098aa5b1dcfeab1cde04c173cc6 100644 (file)
@@ -706,7 +706,7 @@ class Environment:
         return compile(source, filename, "exec")
 
     @typing.overload
-    def compile(  # type: ignore
+    def compile(
         self,
         source: t.Union[str, nodes.Template],
         name: t.Optional[str] = None,
@@ -1248,7 +1248,7 @@ class Template:
         namespace: t.MutableMapping[str, t.Any],
         globals: t.MutableMapping[str, t.Any],
     ) -> "Template":
-        t: "Template" = object.__new__(cls)
+        t: Template = object.__new__(cls)
         t.environment = environment
         t.globals = globals
         t.name = namespace["name"]
index acd11976e4fc74486025a4e480991cb82e64091a..14208770df9ae138dd9cd32be2551325b59df9a4 100644 (file)
@@ -1116,7 +1116,7 @@ def do_batch(
         {%- endfor %}
         </table>
     """
-    tmp: "t.List[V]" = []
+    tmp: t.List[V] = []
 
     for item in value:
         if len(tmp) == linecount:
index 995ebaa0c8178ddb9e0479e0e9f6d30ed863a785..d6cb635b24a492581c32987ed3b8e5069c573ca7 100644 (file)
@@ -146,7 +146,7 @@ class Symbols:
 
     def dump_stores(self) -> t.Dict[str, str]:
         rv: t.Dict[str, str] = {}
-        node: t.Optional["Symbols"] = self
+        node: t.Optional[Symbols] = self
 
         while node is not None:
             for name in sorted(node.stores):
@@ -159,7 +159,7 @@ class Symbols:
 
     def dump_param_targets(self) -> t.Set[str]:
         rv = set()
-        node: t.Optional["Symbols"] = self
+        node: t.Optional[Symbols] = self
 
         while node is not None:
             for target, (instr, _) in self.loads.items():
index 62b0471a3a6a37c9b17d5042f606f3fa64009d6a..6dc94b67d2c8a474837bfd72d23d86299e521d17 100644 (file)
@@ -329,7 +329,7 @@ class TokenStream:
         filename: t.Optional[str],
     ):
         self._iter = iter(generator)
-        self._pushed: "te.Deque[Token]" = deque()
+        self._pushed: te.Deque[Token] = deque()
         self.name = name
         self.filename = filename
         self.closed = False
index 0ec997fb4993ed6bf9564835f316a9cb7469089e..22f3f81f7ec4f77e15a737a7d680d06a296fc04c 100644 (file)
@@ -64,7 +64,7 @@ class Parser:
         self.filename = filename
         self.closed = False
         self.extensions: t.Dict[
-            str, t.Callable[["Parser"], t.Union[nodes.Node, t.List[nodes.Node]]]
+            str, t.Callable[[Parser], t.Union[nodes.Node, t.List[nodes.Node]]]
         ] = {}
         for extension in environment.iter_extensions():
             for tag in extension.tags:
index 4325c8deb22aa03046725ae3645e7b404c613aa4..53582ae8bc742673eeeaacbf54e60a62a8b2bf05 100644 (file)
@@ -172,7 +172,7 @@ class Context:
     ):
         self.parent = parent
         self.vars: t.Dict[str, t.Any] = {}
-        self.environment: "Environment" = environment
+        self.environment: Environment = environment
         self.eval_ctx = EvalContext(self.environment, name)
         self.exported_vars: t.Set[str] = set()
         self.name = name
index 0b4fc12d3479772f15c20ad394aab575fd2a4975..ce276156cb0aea8bfa306044646052a8029b9bcb 100644 (file)
@@ -5,11 +5,11 @@ Useful when the template itself comes from an untrusted source.
 import operator
 import types
 import typing as t
+from _string import formatter_field_name_split  # type: ignore
 from collections import abc
 from collections import deque
 from string import Formatter
 
-from _string import formatter_field_name_split  # type: ignore
 from markupsafe import EscapeFormatter
 from markupsafe import Markup
 
index 7fb76935aa3efbca683b5f6f147e7cdd85a9e869..5c1ff5d7ba751c18c29346b829228e885cd202de 100644 (file)
@@ -428,7 +428,7 @@ class LRUCache:
     def __init__(self, capacity: int) -> None:
         self.capacity = capacity
         self._mapping: t.Dict[t.Any, t.Any] = {}
-        self._queue: "te.Deque[t.Any]" = deque()
+        self._queue: te.Deque[t.Any] = deque()
         self._postinit()
 
     def _postinit(self) -> None: