]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
remove deprecated template function decorators
authorDavid Lord <davidism@gmail.com>
Tue, 9 Nov 2021 20:42:59 +0000 (12:42 -0800)
committerDavid Lord <davidism@gmail.com>
Wed, 10 Nov 2021 19:07:04 +0000 (11:07 -0800)
CHANGES.rst
docs/api.rst
src/jinja2/__init__.py
src/jinja2/filters.py
src/jinja2/utils.py

index 28b2928832a2a823d4976f785c8a5394df3c0bd4..5bb8e9f9c3f591a57c7f885766be81b72aeaafeb 100644 (file)
@@ -9,6 +9,11 @@ Unreleased
 -   Remove previously deprecated code. :pr:`1544`
 
     -   ``WithExtension`` and ``AutoEscapeExtension`` are built-in now.
+    -   ``contextfilter`` and ``contextfunction`` are replaced by
+        ``pass_context``. ``evalcontextfilter`` and
+        ``evalcontextfunction`` are replaced by ``pass_eval_context``.
+        ``environmentfilter`` and ``environmentfunction`` are replaced
+        by ``pass_environment``.
 
 
 Version 3.0.3
index 9c6f3a1289ff2cab9df80b02717cbde4d1ac5e65..d3d54bf41822786deb0bd01eac62242647e7122f 100644 (file)
@@ -597,18 +597,6 @@ functions to a Jinja environment.
 
 .. autofunction:: jinja2.pass_environment
 
-.. autofunction:: jinja2.contextfilter
-
-.. autofunction:: jinja2.evalcontextfilter
-
-.. autofunction:: jinja2.environmentfilter
-
-.. autofunction:: jinja2.contextfunction
-
-.. autofunction:: jinja2.evalcontextfunction
-
-.. autofunction:: jinja2.environmentfunction
-
 .. autofunction:: jinja2.clear_caches
 
 .. autofunction:: jinja2.is_undefined
index 2c3e66bcd90a60e7d1bd77ba4919df3fae5e150f..ebac17689c415ead6225c4820a63aa426838635b 100644 (file)
@@ -14,9 +14,6 @@ from .exceptions import TemplateRuntimeError as TemplateRuntimeError
 from .exceptions import TemplatesNotFound as TemplatesNotFound
 from .exceptions import TemplateSyntaxError as TemplateSyntaxError
 from .exceptions import UndefinedError as UndefinedError
-from .filters import contextfilter
-from .filters import environmentfilter
-from .filters import evalcontextfilter
 from .loaders import BaseLoader as BaseLoader
 from .loaders import ChoiceLoader as ChoiceLoader
 from .loaders import DictLoader as DictLoader
@@ -31,10 +28,7 @@ from .runtime import make_logging_undefined as make_logging_undefined
 from .runtime import StrictUndefined as StrictUndefined
 from .runtime import Undefined as Undefined
 from .utils import clear_caches as clear_caches
-from .utils import contextfunction
-from .utils import environmentfunction
 from .utils import escape
-from .utils import evalcontextfunction
 from .utils import is_undefined as is_undefined
 from .utils import Markup
 from .utils import pass_context as pass_context
index ffb98bf4e338a00fb5b1ef9711999d0945019c1c..fc5f0c8693cd2e238f9e3eed350a17f5fcb48152 100644 (file)
@@ -4,7 +4,6 @@ import random
 import re
 import typing
 import typing as t
-import warnings
 from collections import abc
 from itertools import chain
 from itertools import groupby
@@ -44,58 +43,6 @@ K = t.TypeVar("K")
 V = t.TypeVar("V")
 
 
-def contextfilter(f: F) -> F:
-    """Pass the context as the first argument to the decorated function.
-
-    .. deprecated:: 3.0
-        Will be removed in Jinja 3.1. Use :func:`~jinja2.pass_context`
-        instead.
-    """
-    warnings.warn(
-        "'contextfilter' is renamed to 'pass_context', the old name"
-        " will be removed in Jinja 3.1.",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return pass_context(f)
-
-
-def evalcontextfilter(f: F) -> F:
-    """Pass the eval context as the first argument to the decorated
-    function.
-
-    .. deprecated:: 3.0
-        Will be removed in Jinja 3.1. Use
-        :func:`~jinja2.pass_eval_context` instead.
-
-    .. versionadded:: 2.4
-    """
-    warnings.warn(
-        "'evalcontextfilter' is renamed to 'pass_eval_context', the old"
-        " name will be removed in Jinja 3.1.",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return pass_eval_context(f)
-
-
-def environmentfilter(f: F) -> F:
-    """Pass the environment as the first argument to the decorated
-    function.
-
-    .. deprecated:: 3.0
-        Will be removed in Jinja 3.1. Use
-        :func:`~jinja2.pass_environment` instead.
-    """
-    warnings.warn(
-        "'environmentfilter' is renamed to 'pass_environment', the old"
-        " name will be removed in Jinja 3.1.",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return pass_environment(f)
-
-
 def ignore_case(value: V) -> V:
     """For use as a postprocessor for :func:`make_attrgetter`. Converts strings
     to lowercase and returns other types as-is."""
index 567185f41fcf9fb6532be46d5c848e0c0d16c3c6..976cf711ae4a75b5f062b7d1a5ca21f76540b355 100644 (file)
@@ -84,74 +84,9 @@ class _PassArg(enum.Enum):
         if hasattr(obj, "jinja_pass_arg"):
             return obj.jinja_pass_arg  # type: ignore
 
-        for prefix in "context", "eval_context", "environment":
-            squashed = prefix.replace("_", "")
-
-            for name in f"{squashed}function", f"{squashed}filter":
-                if getattr(obj, name, False) is True:
-                    warnings.warn(
-                        f"{name!r} is deprecated and will stop working"
-                        f" in Jinja 3.1. Use 'pass_{prefix}' instead.",
-                        DeprecationWarning,
-                        stacklevel=2,
-                    )
-                    return cls[prefix]
-
         return None
 
 
-def contextfunction(f: F) -> F:
-    """Pass the context as the first argument to the decorated function.
-
-    .. deprecated:: 3.0
-        Will be removed in Jinja 3.1. Use :func:`~jinja2.pass_context`
-        instead.
-    """
-    warnings.warn(
-        "'contextfunction' is renamed to 'pass_context', the old name"
-        " will be removed in Jinja 3.1.",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return pass_context(f)
-
-
-def evalcontextfunction(f: F) -> F:
-    """Pass the eval context as the first argument to the decorated
-    function.
-
-    .. deprecated:: 3.0
-        Will be removed in Jinja 3.1. Use
-        :func:`~jinja2.pass_eval_context` instead.
-
-    .. versionadded:: 2.4
-    """
-    warnings.warn(
-        "'evalcontextfunction' is renamed to 'pass_eval_context', the"
-        " old name will be removed in Jinja 3.1.",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return pass_eval_context(f)
-
-
-def environmentfunction(f: F) -> F:
-    """Pass the environment as the first argument to the decorated
-    function.
-
-    .. deprecated:: 3.0
-        Will be removed in Jinja 3.1. Use
-        :func:`~jinja2.pass_environment` instead.
-    """
-    warnings.warn(
-        "'environmentfunction' is renamed to 'pass_environment', the"
-        " old name will be removed in Jinja 3.1.",
-        DeprecationWarning,
-        stacklevel=2,
-    )
-    return pass_environment(f)
-
-
 def internalcode(f: F) -> F:
     """Marks the function as internally used"""
     internal_code.add(f.__code__)