Don't register tests as filters. Fixes #55319

pull/55332/head
Matt Martz 7 years ago
parent f8c47262c4
commit fef8ff8a8c

@ -0,0 +1,2 @@
minor_changes:
- Jinja tests - Remove deprecated functionality of registering tests as filters (https://github.com/ansible/ansible/issues/55319)

@ -178,26 +178,6 @@ def _count_newlines_from_end(in_str):
return i
def tests_as_filters_warning(name, func):
'''
Closure to enable displaying a deprecation warning when tests are used as a filter
This closure is only used when registering ansible provided tests as filters
This function should be removed in 2.9 along with registering ansible provided tests as filters
in Templar._get_filters
'''
@wraps(func)
def wrapper(*args, **kwargs):
display.deprecated(
'Using tests as filters is deprecated. Instead of using `result|%(name)s` use '
'`result is %(name)s`' % dict(name=name),
version='2.9'
)
return func(*args, **kwargs)
return wrapper
class AnsibleUndefined(StrictUndefined):
'''
A custom Undefined class, which returns further Undefined objects on access,
@ -422,13 +402,6 @@ class Templar:
self._filters = dict()
# TODO: Remove registering tests as filters in 2.9
for name, func in self._get_tests().items():
if name in builtin_filters:
# If we have a custom test named the same as a builtin filter, don't register as a filter
continue
self._filters[name] = tests_as_filters_warning(name, func)
for fp in self._filter_loader.all():
self._filters.update(fp.filters())

Loading…
Cancel
Save