summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Lord <davidism@gmail.com>2021-12-26 07:48:45 -0700
committerDavid Lord <davidism@gmail.com>2021-12-26 07:48:45 -0700
commit896a62135bcc151f2997e028c5125bec2cb2431f (patch)
treedca4a04fa2f9fc5b78c215ea236a709ce5419041 /src
parent7d72eb7fefb7dce065193967f31f805180508448 (diff)
parent54262978d60902e777df029a20ebb74ba6985f2f (diff)
downloadjinja2-896a62135bcc151f2997e028c5125bec2cb2431f.tar.gz
Merge branch '3.0.x'
Diffstat (limited to 'src')
-rw-r--r--src/jinja2/compiler.py2
-rw-r--r--src/jinja2/environment.py12
-rw-r--r--src/jinja2/ext.py2
-rw-r--r--src/jinja2/filters.py2
-rw-r--r--src/jinja2/idtracking.py2
-rw-r--r--src/jinja2/lexer.py2
-rw-r--r--src/jinja2/loaders.py2
-rw-r--r--src/jinja2/parser.py2
-rw-r--r--src/jinja2/sandbox.py2
-rw-r--r--src/jinja2/visitor.py2
10 files changed, 15 insertions, 15 deletions
diff --git a/src/jinja2/compiler.py b/src/jinja2/compiler.py
index ce6f2c5..dfea00a 100644
--- a/src/jinja2/compiler.py
+++ b/src/jinja2/compiler.py
@@ -218,7 +218,7 @@ class Frame:
def copy(self) -> "Frame":
"""Create a copy of the current one."""
- rv = t.cast(Frame, object.__new__(self.__class__))
+ rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.symbols = self.symbols.copy()
return rv
diff --git a/src/jinja2/environment.py b/src/jinja2/environment.py
index 85ac0b3..0c380c8 100644
--- a/src/jinja2/environment.py
+++ b/src/jinja2/environment.py
@@ -939,7 +939,7 @@ class Environment:
@internalcode
def _load_template(
- self, name: str, globals: t.Optional[t.Mapping[str, t.Any]]
+ self, name: str, globals: t.Optional[t.MutableMapping[str, t.Any]]
) -> "Template":
if self.loader is None:
raise TypeError("no loader for this environment specified")
@@ -967,7 +967,7 @@ class Environment:
self,
name: t.Union[str, "Template"],
parent: t.Optional[str] = None,
- globals: t.Optional[t.Mapping[str, t.Any]] = None,
+ globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
) -> "Template":
"""Load a template by name with :attr:`loader` and return a
:class:`Template`. If the template does not exist a
@@ -1002,7 +1002,7 @@ class Environment:
self,
names: t.Iterable[t.Union[str, "Template"]],
parent: t.Optional[str] = None,
- globals: t.Optional[t.Mapping[str, t.Any]] = None,
+ globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
) -> "Template":
"""Like :meth:`get_template`, but tries loading multiple names.
If none of the names can be loaded a :exc:`TemplatesNotFound`
@@ -1058,7 +1058,7 @@ class Environment:
str, "Template", t.List[t.Union[str, "Template"]]
],
parent: t.Optional[str] = None,
- globals: t.Optional[t.Mapping[str, t.Any]] = None,
+ globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
) -> "Template":
"""Use :meth:`select_template` if an iterable of template names
is given, or :meth:`get_template` if one name is given.
@@ -1074,7 +1074,7 @@ class Environment:
def from_string(
self,
source: t.Union[str, nodes.Template],
- globals: t.Optional[t.Mapping[str, t.Any]] = None,
+ globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
template_class: t.Optional[t.Type["Template"]] = None,
) -> "Template":
"""Load a template from a source string without using
@@ -1093,7 +1093,7 @@ class Environment:
return cls.from_code(self, self.compile(source), gs, None)
def make_globals(
- self, d: t.Optional[t.Mapping[str, t.Any]]
+ self, d: t.Optional[t.MutableMapping[str, t.Any]]
) -> t.MutableMapping[str, t.Any]:
"""Make the globals map for a template. Any given template
globals overlay the environment :attr:`globals`.
diff --git a/src/jinja2/ext.py b/src/jinja2/ext.py
index 2377a37..d21b83a 100644
--- a/src/jinja2/ext.py
+++ b/src/jinja2/ext.py
@@ -90,7 +90,7 @@ class Extension:
def bind(self, environment: Environment) -> "Extension":
"""Create a copy of this extension bound to another environment."""
- rv = t.cast(Extension, object.__new__(self.__class__))
+ rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.environment = environment
return rv
diff --git a/src/jinja2/filters.py b/src/jinja2/filters.py
index fc5f0c8..b67c801 100644
--- a/src/jinja2/filters.py
+++ b/src/jinja2/filters.py
@@ -362,7 +362,7 @@ def do_sort(
.. sourcecode:: jinja
- {% for user users|sort(attribute="age,name") %}
+ {% for user in users|sort(attribute="age,name") %}
...
{% endfor %}
diff --git a/src/jinja2/idtracking.py b/src/jinja2/idtracking.py
index 38c525e..995ebaa 100644
--- a/src/jinja2/idtracking.py
+++ b/src/jinja2/idtracking.py
@@ -84,7 +84,7 @@ class Symbols:
return rv
def copy(self) -> "Symbols":
- rv = t.cast(Symbols, object.__new__(self.__class__))
+ rv = object.__new__(self.__class__)
rv.__dict__.update(self.__dict__)
rv.refs = self.refs.copy()
rv.loads = self.loads.copy()
diff --git a/src/jinja2/lexer.py b/src/jinja2/lexer.py
index c25ab0f..b46a7e1 100644
--- a/src/jinja2/lexer.py
+++ b/src/jinja2/lexer.py
@@ -723,7 +723,7 @@ class Lexer:
# tuples support more options
if isinstance(tokens, tuple):
- groups = m.groups()
+ groups: t.Sequence[str] = m.groups()
if isinstance(tokens, OptionalLStrip):
# Rule supports lstrip. Match will look like
diff --git a/src/jinja2/loaders.py b/src/jinja2/loaders.py
index 4fac3a0..d7d9bd0 100644
--- a/src/jinja2/loaders.py
+++ b/src/jinja2/loaders.py
@@ -603,7 +603,7 @@ class ModuleLoader(BaseLoader):
if not isinstance(path, abc.Iterable) or isinstance(path, str):
path = [path]
- mod.__path__ = [os.fspath(p) for p in path] # type: ignore
+ mod.__path__ = [os.fspath(p) for p in path]
sys.modules[package_name] = weakref.proxy(
mod, lambda x: sys.modules.pop(package_name, None)
diff --git a/src/jinja2/parser.py b/src/jinja2/parser.py
index 7ad73fc..4447396 100644
--- a/src/jinja2/parser.py
+++ b/src/jinja2/parser.py
@@ -160,7 +160,7 @@ class Parser:
self._last_identifier += 1
rv = object.__new__(nodes.InternalName)
nodes.Node.__init__(rv, f"fi{self._last_identifier}", lineno=lineno)
- return rv # type: ignore
+ return rv
def parse_statement(self) -> t.Union[nodes.Node, t.List[nodes.Node]]:
"""Parse a single statement."""
diff --git a/src/jinja2/sandbox.py b/src/jinja2/sandbox.py
index 4294884..06d7414 100644
--- a/src/jinja2/sandbox.py
+++ b/src/jinja2/sandbox.py
@@ -409,7 +409,7 @@ class ImmutableSandboxedEnvironment(SandboxedEnvironment):
class SandboxedFormatter(Formatter):
def __init__(self, env: Environment, **kwargs: t.Any) -> None:
self._env = env
- super().__init__(**kwargs) # type: ignore
+ super().__init__(**kwargs)
def get_field(
self, field_name: str, args: t.Sequence[t.Any], kwargs: t.Mapping[str, t.Any]
diff --git a/src/jinja2/visitor.py b/src/jinja2/visitor.py
index b150e57..71e341e 100644
--- a/src/jinja2/visitor.py
+++ b/src/jinja2/visitor.py
@@ -30,7 +30,7 @@ class NodeVisitor:
exists for this node. In that case the generic visit function is
used instead.
"""
- return getattr(self, f"visit_{type(node).__name__}", None) # type: ignore
+ return getattr(self, f"visit_{type(node).__name__}", None)
def visit(self, node: Node, *args: t.Any, **kwargs: t.Any) -> t.Any:
"""Visit a node."""