Don't register tests as filters (#55332)

* Don't register tests as filters. Fixes #55319

* Remove tests for deprecated functionality

* Remove no-tests-as-filters sanity tests

* Remove docs too

* Revert "Remove docs too"

This reverts commit 7daf457a742e67ec6e91964852c7f804507b46b8.

* Make no-tests-as-filters doc an orphan
This commit is contained in:
Matt Martz
2019-04-16 14:10:14 -05:00
committed by GitHub
parent 960df24272
commit 9f83139dcb
6 changed files with 4 additions and 151 deletions

View File

@@ -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())