Skip to content
Myr

apply ruff fixes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 65b27af · Browse files · 11 files+12 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

11 files+12 added−13 removed

  • other:+12 added−13 removed

11 files+12 added−13 removed

modified:src/jinja2/async_utils.py+1 added-1 removed
65 unmodified lines
6667 if inspect.isawaitable(value):68 return await t.cast("t.Awaitable[V]", value)6970 return t.cast("V", value)70 return value717273class _IteratorToAsyncIterator(t.Generic[V]):74 def __init__(self, iterator: "t.Iterator[V]"):
25 unmodified lines
modified:src/jinja2/debug.py+1 added-1 removed
150 unmodified lines
151 """Based on the runtime locals, get the context that would be152 available at that point in the template.153 """154 # Start with the current template context.155 ctx: "t.Optional[Context]" = real_locals.get("context")155 ctx: t.Optional[Context] = real_locals.get("context")156157 if ctx is not None:158 data: t.Dict[str, t.Any] = ctx.get_all().copy()159 else:
32 unmodified lines
modified:src/jinja2/environment.py+2 added-2 removed
704 unmodified lines
705 """706 return compile(source, filename, "exec")707708 @typing.overload709 def compile( # type: ignore709 def compile(710 self,711 source: t.Union[str, nodes.Template],712 name: t.Optional[str] = None,713 filename: t.Optional[str] = None,
533 unmodified lines
1247 environment: Environment,1248 namespace: t.MutableMapping[str, t.Any],1249 globals: t.MutableMapping[str, t.Any],1250 ) -> "Template":1251 t: "Template" = object.__new__(cls)1251 t: Template = object.__new__(cls)1252 t.environment = environment1253 t.globals = globals1254 t.name = namespace["name"]1255 t.filename = namespace["__file__"]
414 unmodified lines
modified:src/jinja2/filters.py+1 added-1 removed
1114 unmodified lines
1115 </tr>1116 {%- endfor %}1117 </table>1118 """1119 tmp: "t.List[V]" = []1119 tmp: t.List[V] = []11201121 for item in value:1122 if len(tmp) == linecount:1123 yield tmp
743 unmodified lines
modified:src/jinja2/idtracking.py+2 added-2 removed
144 unmodified lines
145 self.loads[target] = (VAR_LOAD_RESOLVE, name)146147 def dump_stores(self) -> t.Dict[str, str]:148 rv: t.Dict[str, str] = {}149 node: t.Optional["Symbols"] = self149 node: t.Optional[Symbols] = self150151 while node is not None:152 for name in sorted(node.stores):153 if name not in rv:
4 unmodified lines
158 return rv159160 def dump_param_targets(self) -> t.Set[str]:161 rv = set()162 node: t.Optional["Symbols"] = self162 node: t.Optional[Symbols] = self163164 while node is not None:165 for target, (instr, _) in self.loads.items():166 if instr == VAR_LOAD_PARAMETER:
152 unmodified lines
modified:src/jinja2/lexer.py+1 added-1 removed
327 unmodified lines
328 name: t.Optional[str],329 filename: t.Optional[str],330 ):331 self._iter = iter(generator)332 self._pushed: "te.Deque[Token]" = deque()332 self._pushed: te.Deque[Token] = deque()333 self.name = name334 self.filename = filename335 self.closed = False336 self.current = Token(1, TOKEN_INITIAL, "")
532 unmodified lines
modified:src/jinja2/parser.py+1 added-1 removed
62 unmodified lines
63 self.name = name64 self.filename = filename65 self.closed = False66 self.extensions: t.Dict[67 str, t.Callable[["Parser"], t.Union[nodes.Node, t.List[nodes.Node]]]67 str, t.Callable[[Parser], t.Union[nodes.Node, t.List[nodes.Node]]]68 ] = {}69 for extension in environment.iter_extensions():70 for tag in extension.tags:71 self.extensions[tag] = extension.parse
970 unmodified lines
modified:src/jinja2/runtime.py+1 added-1 removed
170 unmodified lines
171 globals: t.Optional[t.MutableMapping[str, t.Any]] = None,172 ):173 self.parent = parent174 self.vars: t.Dict[str, t.Any] = {}175 self.environment: "Environment" = environment175 self.environment: Environment = environment176 self.eval_ctx = EvalContext(self.environment, name)177 self.exported_vars: t.Set[str] = set()178 self.name = name179 self.globals_keys = set() if globals is None else set(globals)
877 unmodified lines
modified:src/jinja2/sandbox.py+1 added-1 removed
3 unmodified lines
45import operator6import types7import typing as t8from _string import formatter_field_name_split # type: ignore9from collections import abc10from collections import deque11from string import Formatter1212from _string import formatter_field_name_split # type: ignore13from markupsafe import EscapeFormatter14from markupsafe import Markup1516from .environment import Environment
413 unmodified lines
modified:src/jinja2/utils.py+1 added-1 removed
426 unmodified lines
427428 def __init__(self, capacity: int) -> None:429 self.capacity = capacity430 self._mapping: t.Dict[t.Any, t.Any] = {}431 self._queue: "te.Deque[t.Any]" = deque()431 self._queue: te.Deque[t.Any] = deque()432 self._postinit()433434 def _postinit(self) -> None:435 # alias all queue methods for faster lookup
320 unmodified lines
modified:pyproject.toml-1 removed
89 unmodified lines
90 "I", # isort91 "UP", # pyupgrade92 "W", # pycodestyle warning93]94ignore-init-module-imports = true9495[tool.ruff.lint.isort]96force-single-line = true97order-by-type = false
5 unmodified lines