Skip to content
Myr

remove deprecated template function decorators

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent ac9dbfc · Browse files · 5 files+5 added−136 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+5 added−136 removed

  • other:+5 added−136 removed

5 files+5 added−136 removed

modified:docs/api.rst-12 removed
595 unmodified lines
596.. autofunction:: jinja2.pass_eval_context597598.. autofunction:: jinja2.pass_environment599600.. autofunction:: jinja2.contextfilter601602.. autofunction:: jinja2.evalcontextfilter603604.. autofunction:: jinja2.environmentfilter605606.. autofunction:: jinja2.contextfunction607608.. autofunction:: jinja2.evalcontextfunction609610.. autofunction:: jinja2.environmentfunction611600.. autofunction:: jinja2.clear_caches601602.. autofunction:: jinja2.is_undefined603
316 unmodified lines
modified:src/jinja2/__init__.py-6 removed
12 unmodified lines
13from .exceptions import TemplateRuntimeError as TemplateRuntimeError14from .exceptions import TemplatesNotFound as TemplatesNotFound15from .exceptions import TemplateSyntaxError as TemplateSyntaxError16from .exceptions import UndefinedError as UndefinedError17from .filters import contextfilter18from .filters import environmentfilter19from .filters import evalcontextfilter17from .loaders import BaseLoader as BaseLoader18from .loaders import ChoiceLoader as ChoiceLoader19from .loaders import DictLoader as DictLoader20from .loaders import FileSystemLoader as FileSystemLoader
6 unmodified lines
27from .runtime import make_logging_undefined as make_logging_undefined28from .runtime import StrictUndefined as StrictUndefined29from .runtime import Undefined as Undefined30from .utils import clear_caches as clear_caches34from .utils import contextfunction35from .utils import environmentfunction31from .utils import escape37from .utils import evalcontextfunction32from .utils import is_undefined as is_undefined33from .utils import Markup34from .utils import pass_context as pass_context35from .utils import pass_environment as pass_environment
4 unmodified lines
modified:src/jinja2/filters.py-53 removed
2 unmodified lines
3import random4import re5import typing6import typing as t7import warnings7from collections import abc8from itertools import chain9from itertools import groupby10
31 unmodified lines
42K = t.TypeVar("K")43V = t.TypeVar("V")444547def contextfilter(f: F) -> F:48 """Pass the context as the first argument to the decorated function.4950 .. deprecated:: 3.051 Will be removed in Jinja 3.1. Use :func:`~jinja2.pass_context`52 instead.53 """54 warnings.warn(55 "'contextfilter' is renamed to 'pass_context', the old name"56 " will be removed in Jinja 3.1.",57 DeprecationWarning,58 stacklevel=2,59 )60 return pass_context(f)616263def evalcontextfilter(f: F) -> F:64 """Pass the eval context as the first argument to the decorated65 function.6667 .. deprecated:: 3.068 Will be removed in Jinja 3.1. Use69 :func:`~jinja2.pass_eval_context` instead.7071 .. versionadded:: 2.472 """73 warnings.warn(74 "'evalcontextfilter' is renamed to 'pass_eval_context', the old"75 " name will be removed in Jinja 3.1.",76 DeprecationWarning,77 stacklevel=2,78 )79 return pass_eval_context(f)808182def environmentfilter(f: F) -> F:83 """Pass the environment as the first argument to the decorated84 function.8586 .. deprecated:: 3.087 Will be removed in Jinja 3.1. Use88 :func:`~jinja2.pass_environment` instead.89 """90 warnings.warn(91 "'environmentfilter' is renamed to 'pass_environment', the old"92 " name will be removed in Jinja 3.1.",93 DeprecationWarning,94 stacklevel=2,95 )96 return pass_environment(f)979846def ignore_case(value: V) -> V:47 """For use as a postprocessor for :func:`make_attrgetter`. Converts strings48 to lowercase and returns other types as-is."""49 if isinstance(value, str):
1722 unmodified lines
modified:src/jinja2/utils.py-65 removed
82 unmodified lines
83 def from_obj(cls, obj: F) -> t.Optional["_PassArg"]:84 if hasattr(obj, "jinja_pass_arg"):85 return obj.jinja_pass_arg # type: ignore8687 for prefix in "context", "eval_context", "environment":88 squashed = prefix.replace("_", "")8990 for name in f"{squashed}function", f"{squashed}filter":91 if getattr(obj, name, False) is True:92 warnings.warn(93 f"{name!r} is deprecated and will stop working"94 f" in Jinja 3.1. Use 'pass_{prefix}' instead.",95 DeprecationWarning,96 stacklevel=2,97 )98 return cls[prefix]9987 return None8889103def contextfunction(f: F) -> F:104 """Pass the context as the first argument to the decorated function.105106 .. deprecated:: 3.0107 Will be removed in Jinja 3.1. Use :func:`~jinja2.pass_context`108 instead.109 """110 warnings.warn(111 "'contextfunction' is renamed to 'pass_context', the old name"112 " will be removed in Jinja 3.1.",113 DeprecationWarning,114 stacklevel=2,115 )116 return pass_context(f)117118119def evalcontextfunction(f: F) -> F:120 """Pass the eval context as the first argument to the decorated121 function.122123 .. deprecated:: 3.0124 Will be removed in Jinja 3.1. Use125 :func:`~jinja2.pass_eval_context` instead.126127 .. versionadded:: 2.4128 """129 warnings.warn(130 "'evalcontextfunction' is renamed to 'pass_eval_context', the"131 " old name will be removed in Jinja 3.1.",132 DeprecationWarning,133 stacklevel=2,134 )135 return pass_eval_context(f)136137138def environmentfunction(f: F) -> F:139 """Pass the environment as the first argument to the decorated140 function.141142 .. deprecated:: 3.0143 Will be removed in Jinja 3.1. Use144 :func:`~jinja2.pass_environment` instead.145 """146 warnings.warn(147 "'environmentfunction' is renamed to 'pass_environment', the"148 " old name will be removed in Jinja 3.1.",149 DeprecationWarning,150 stacklevel=2,151 )152 return pass_environment(f)15315490def internalcode(f: F) -> F:91 """Marks the function as internally used"""92 internal_code.add(f.__code__)93 return f
696 unmodified lines
modified:CHANGES.rst+5 added
7 unmodified lines
8- Drop support for Python 3.6. :pr:`1534`9- Remove previously deprecated code. :pr:`1544`1011 - ``WithExtension`` and ``AutoEscapeExtension`` are built-in now.12 - ``contextfilter`` and ``contextfunction`` are replaced by13 ``pass_context``. ``evalcontextfilter`` and14 ``evalcontextfunction`` are replaced by ``pass_eval_context``.15 ``environmentfilter`` and ``environmentfunction`` are replaced16 by ``pass_environment``.171819Version 3.0.320-------------
911 unmodified lines