jinja2.contextfilter decorator renamed to pass_context (#51007)

* jinja2.contextfilter decorator renamed to pass_context

* bump jinja2 dependency
This commit is contained in:
Matt Zimmerman 2021-05-24 08:38:37 -07:00 committed by GitHub
parent 987e8ed5ed
commit e964c607a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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",