Skip to content

Commit 990602f

Browse files
authored
Merge pull request #1647 from Tom-Brouwer/202204/add-missing-overlay-options
Add missing environment options to the Environment.overlay method
2 parents ea69e41 + 5d3d241 commit 990602f

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGES.rst

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Version 3.1.2
55

66
Unreleased
77

8+
- Add parameters to ``Environment.overlay`` to match ``__init__``.
9+
:issue:`1645`
10+
811

912
Version 3.1.1
1013
-------------

src/jinja2/environment.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ def overlay(
393393
line_comment_prefix: t.Optional[str] = missing,
394394
trim_blocks: bool = missing,
395395
lstrip_blocks: bool = missing,
396+
newline_sequence: "te.Literal['\\n', '\\r\\n', '\\r']" = missing,
397+
keep_trailing_newline: bool = missing,
396398
extensions: t.Sequence[t.Union[str, t.Type["Extension"]]] = missing,
397399
optimized: bool = missing,
398400
undefined: t.Type[Undefined] = missing,
@@ -402,6 +404,7 @@ def overlay(
402404
cache_size: int = missing,
403405
auto_reload: bool = missing,
404406
bytecode_cache: t.Optional["BytecodeCache"] = missing,
407+
enable_async: bool = False,
405408
) -> "Environment":
406409
"""Create a new overlay environment that shares all the data with the
407410
current environment except for cache and the overridden attributes.
@@ -413,9 +416,13 @@ def overlay(
413416
up completely. Not all attributes are truly linked, some are just
414417
copied over so modifications on the original environment may not shine
415418
through.
419+
420+
.. versionchanged:: 3.1.2
421+
Added the ``newline_sequence``,, ``keep_trailing_newline``,
422+
and ``enable_async`` parameters to match ``__init__``.
416423
"""
417424
args = dict(locals())
418-
del args["self"], args["cache_size"], args["extensions"]
425+
del args["self"], args["cache_size"], args["extensions"], args["enable_async"]
419426

420427
rv = object.__new__(self.__class__)
421428
rv.__dict__.update(self.__dict__)
@@ -437,6 +444,9 @@ def overlay(
437444
if extensions is not missing:
438445
rv.extensions.update(load_extensions(rv, extensions))
439446

447+
if enable_async is not missing:
448+
rv.is_async = enable_async
449+
440450
return _environment_config_check(rv)
441451

442452
@property

src/jinja2/visitor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def visit(self, node: Node, *args: t.Any, **kwargs: t.Any) -> t.Any:
4343

4444
def generic_visit(self, node: Node, *args: t.Any, **kwargs: t.Any) -> t.Any:
4545
"""Called if no explicit visitor function exists for a node."""
46-
for node in node.iter_child_nodes():
47-
self.visit(node, *args, **kwargs)
46+
for child_node in node.iter_child_nodes():
47+
self.visit(child_node, *args, **kwargs)
4848

4949

5050
class NodeTransformer(NodeVisitor):

0 commit comments

Comments
 (0)