From: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com> Date: Mon, 28 Mar 2022 04:33:49 +0000 (-0500) Subject: add note on type ignore in templating.py (#1556) X-Git-Tag: 0.19.1~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eeb0457aed1cfc2d33cd85157825f2d2de4a2026;p=thirdparty%2Fstarlette.git add note on type ignore in templating.py (#1556) * add note on type ignore * Update templating.py * Update templating.py * Update templating.py --- diff --git a/starlette/templating.py b/starlette/templating.py index cfc4a766..27939c95 100644 --- a/starlette/templating.py +++ b/starlette/templating.py @@ -8,7 +8,10 @@ from starlette.types import Receive, Scope, Send try: import jinja2 - # @contextfunction renamed to @pass_context in Jinja 3.0, to be removed in 3.1 + # @contextfunction was renamed to @pass_context in Jinja 3.0, and was removed in 3.1 + # hence we try to get pass_context (most installs will be >=3.1) + # and fall back to contextfunction, + # adding a type ignore for mypy to let us access an attribute that may not exist if hasattr(jinja2, "pass_context"): pass_context = jinja2.pass_context else: # pragma: nocover