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
Provenance
- Commit
c6caa4c- Tree
d5245e7- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
ac9dbfc
5 files changed+5 added−136 removed
modified:docs/api.rst-12 removed
595 unmodified lines596 .. autofunction:: jinja2.pass_eval_context597 598 .. autofunction:: jinja2.pass_environment599 600-.. autofunction:: jinja2.contextfilter601-602-.. autofunction:: jinja2.evalcontextfilter603-604-.. autofunction:: jinja2.environmentfilter605-606-.. autofunction:: jinja2.contextfunction607-608-.. autofunction:: jinja2.evalcontextfunction609-610-.. autofunction:: jinja2.environmentfunction611-600 .. autofunction:: jinja2.clear_caches601 602 .. autofunction:: jinja2.is_undefined603 316 unmodified linesmodified:src/jinja2/__init__.py-6 removed
12 unmodified lines13 from .exceptions import TemplateRuntimeError as TemplateRuntimeError14 from .exceptions import TemplatesNotFound as TemplatesNotFound15 from .exceptions import TemplateSyntaxError as TemplateSyntaxError16 from .exceptions import UndefinedError as UndefinedError17-from .filters import contextfilter18-from .filters import environmentfilter19-from .filters import evalcontextfilter17 from .loaders import BaseLoader as BaseLoader18 from .loaders import ChoiceLoader as ChoiceLoader19 from .loaders import DictLoader as DictLoader20 from .loaders import FileSystemLoader as FileSystemLoader6 unmodified lines27 from .runtime import make_logging_undefined as make_logging_undefined28 from .runtime import StrictUndefined as StrictUndefined29 from .runtime import Undefined as Undefined30 from .utils import clear_caches as clear_caches34-from .utils import contextfunction35-from .utils import environmentfunction31 from .utils import escape37-from .utils import evalcontextfunction32 from .utils import is_undefined as is_undefined33 from .utils import Markup34 from .utils import pass_context as pass_context35 from .utils import pass_environment as pass_environment4 unmodified linesmodified:src/jinja2/filters.py-53 removed
2 unmodified lines3 import random4 import re5 import typing6 import typing as t7-import warnings7 from collections import abc8 from itertools import chain9 from itertools import groupby10 31 unmodified lines42 K = t.TypeVar("K")43 V = t.TypeVar("V")44 45 47-def contextfilter(f: F) -> F:48- """Pass the context as the first argument to the decorated function.49-50- .. 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)61-62-63-def evalcontextfilter(f: F) -> F:64- """Pass the eval context as the first argument to the decorated65- function.66-67- .. deprecated:: 3.068- Will be removed in Jinja 3.1. Use69- :func:`~jinja2.pass_eval_context` instead.70-71- .. 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)80-81-82-def environmentfilter(f: F) -> F:83- """Pass the environment as the first argument to the decorated84- function.85-86- .. 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)97-98-46 def 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 linesmodified:src/jinja2/utils.py-65 removed
82 unmodified lines83 def from_obj(cls, obj: F) -> t.Optional["_PassArg"]:84 if hasattr(obj, "jinja_pass_arg"):85 return obj.jinja_pass_arg # type: ignore86 87- for prefix in "context", "eval_context", "environment":88- squashed = prefix.replace("_", "")89-90- 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]99-87 return None88 89 103-def contextfunction(f: F) -> F:104- """Pass the context as the first argument to the decorated function.105-106- .. 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)117-118-119-def evalcontextfunction(f: F) -> F:120- """Pass the eval context as the first argument to the decorated121- function.122-123- .. deprecated:: 3.0124- Will be removed in Jinja 3.1. Use125- :func:`~jinja2.pass_eval_context` instead.126-127- .. 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)136-137-138-def environmentfunction(f: F) -> F:139- """Pass the environment as the first argument to the decorated140- function.141-142- .. 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)153-154-90 def internalcode(f: F) -> F:91 """Marks the function as internally used"""92 internal_code.add(f.__code__)93 return f696 unmodified linesmodified:CHANGES.rst+5 added
7 unmodified lines8 - Drop support for Python 3.6. :pr:`1534`9 - Remove previously deprecated code. :pr:`1544`10 11 - ``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``.17 18 19 Version 3.0.320 -------------911 unmodified lines