Skip to content

Commit

Permalink
add note on type ignore in templating.py (#1556)
Browse files Browse the repository at this point in the history
* add note on type ignore

* Update templating.py

* Update templating.py

* Update templating.py
  • Loading branch information
adriangb committed Mar 28, 2022
1 parent 710aa62 commit eeb0457
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion starlette/templating.py
Expand Up @@ -8,7 +8,10 @@
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
Expand Down

0 comments on commit eeb0457

Please sign in to comment.