Skip to content

Commit b4b28ec

Browse files
authored
fix default for Environment.overlay(enable_async) (#2061)
2 parents 767b236 + e45bc74 commit b4b28ec

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Unreleased
3434
objects. :issue:`2025`
3535
- Fix `copy`/`pickle` support for the internal ``missing`` object.
3636
:issue:`2027`
37+
- ``Environment.overlay(enable_async)`` is applied correctly. :pr:`2061`
3738

3839

3940
Version 3.1.4

src/jinja2/environment.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def overlay(
406406
cache_size: int = missing,
407407
auto_reload: bool = missing,
408408
bytecode_cache: t.Optional["BytecodeCache"] = missing,
409-
enable_async: bool = False,
409+
enable_async: bool = missing,
410410
) -> "Environment":
411411
"""Create a new overlay environment that shares all the data with the
412412
current environment except for cache and the overridden attributes.
@@ -419,8 +419,11 @@ def overlay(
419419
copied over so modifications on the original environment may not shine
420420
through.
421421
422+
.. versionchanged:: 3.1.5
423+
``enable_async`` is applied correctly.
424+
422425
.. versionchanged:: 3.1.2
423-
Added the ``newline_sequence``,, ``keep_trailing_newline``,
426+
Added the ``newline_sequence``, ``keep_trailing_newline``,
424427
and ``enable_async`` parameters to match ``__init__``.
425428
"""
426429
args = dict(locals())

tests/test_api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,11 @@ class CustomEnvironment(Environment):
425425
env = CustomEnvironment()
426426
tmpl = env.from_string("{{ foo }}")
427427
assert tmpl.render() == "resolve-foo"
428+
429+
430+
def test_overlay_enable_async(env):
431+
assert not env.is_async
432+
assert not env.overlay().is_async
433+
env_async = env.overlay(enable_async=True)
434+
assert env_async.is_async
435+
assert not env_async.overlay(enable_async=False).is_async

0 commit comments

Comments
 (0)