From e964c607a3339f3b2e9c6b524954ae7feee3e3b6 Mon Sep 17 00:00:00 2001 From: Matt Zimmerman Date: Mon, 24 May 2021 08:38:37 -0700 Subject: [PATCH] jinja2.contextfilter decorator renamed to pass_context (#51007) * jinja2.contextfilter decorator renamed to pass_context * bump jinja2 dependency --- homeassistant/helpers/template.py | 10 +++++----- homeassistant/package_constraints.txt | 2 +- requirements.txt | 2 +- setup.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 86223d2a950..f65100a8775 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -22,7 +22,7 @@ from urllib.parse import urlencode as urllib_urlencode import weakref import jinja2 -from jinja2 import contextfilter, contextfunction +from jinja2 import contextfunction, pass_context from jinja2.sandbox import ImmutableSandboxedEnvironment from jinja2.utils import Namespace import voluptuous as vol @@ -1315,7 +1315,7 @@ def to_json(value): return json.dumps(value) -@contextfilter +@pass_context def random_every_time(context, values): """Choose a random value. @@ -1482,7 +1482,7 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment): return contextfunction(wrapper) self.globals["device_entities"] = hassfunction(device_entities) - self.filters["device_entities"] = contextfilter(self.globals["device_entities"]) + self.filters["device_entities"] = pass_context(self.globals["device_entities"]) if limited: # Only device_entities is available to limited templates, mark other @@ -1514,9 +1514,9 @@ class TemplateEnvironment(ImmutableSandboxedEnvironment): return self.globals["expand"] = hassfunction(expand) - self.filters["expand"] = contextfilter(self.globals["expand"]) + self.filters["expand"] = pass_context(self.globals["expand"]) self.globals["closest"] = hassfunction(closest) - self.filters["closest"] = contextfilter(hassfunction(closest_filter)) + self.filters["closest"] = pass_context(hassfunction(closest_filter)) self.globals["distance"] = hassfunction(distance) self.globals["is_state"] = hassfunction(is_state) self.globals["is_state_attr"] = hassfunction(is_state_attr) diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 0202efda332..e3533632af8 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -19,7 +19,7 @@ emoji==1.2.0 hass-nabucasa==0.43.0 home-assistant-frontend==20210518.0 httpx==0.18.0 -jinja2>=2.11.3 +jinja2>=3.0.1 netdisco==2.8.3 paho-mqtt==1.5.1 pillow==8.1.2 diff --git a/requirements.txt b/requirements.txt index 4661a23a70f..7d9b7739669 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ bcrypt==3.1.7 certifi>=2020.12.5 ciso8601==2.1.3 httpx==0.18.0 -jinja2>=2.11.3 +jinja2>=3.0.1 PyJWT==1.7.1 cryptography==3.3.2 pip>=8.0.3,<20.3 diff --git a/setup.py b/setup.py index d987f4671b4..0178b201372 100755 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ REQUIRES = [ "certifi>=2020.12.5", "ciso8601==2.1.3", "httpx==0.18.0", - "jinja2>=2.11.3", + "jinja2>=3.0.1", "PyJWT==1.7.1", # PyJWT has loose dependency. We want the latest one. "cryptography==3.3.2",