From 2e018bb064185605de042ab28ae3ecc3b69ee1f3 Mon Sep 17 00:00:00 2001 From: JustinWayland Date: Tue, 14 Nov 2023 19:55:38 -0500 Subject: [PATCH] Simplify deprecation mechanism Co-Authored-By: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> Co-Authored-By: Matt Martz --- lib/ansible/utils/plugin_docs.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/ansible/utils/plugin_docs.py b/lib/ansible/utils/plugin_docs.py index fed0d3ec576..54f9a5c01eb 100644 --- a/lib/ansible/utils/plugin_docs.py +++ b/lib/ansible/utils/plugin_docs.py @@ -14,7 +14,7 @@ from ansible.module_utils.common.text.converters import to_native from ansible.parsing.plugin_docs import read_docstring from ansible.parsing.yaml.loader import AnsibleLoader from ansible.utils.display import Display -import functools +from ansible.utils.sentinel import Sentinel display = Display() @@ -205,20 +205,14 @@ def add_fragments(doc, filename, fragment_loader, is_module=False): raise AnsibleError('unknown doc_fragment(s) in file {0}: {1}'.format(filename, to_native(', '.join(unknown_fragments)))) -def _handle_deprecated_kwarg(func): - @functools.wraps(func) - def wrapper(*args, **kwargs): - if len(args) >= 6 or 'is_module' in kwargs: - display.deprecated("is_module is deprecated, pass plugin_type='module' instead", version='2.19') - return func(*args, **kwargs) - return wrapper - - -@_handle_deprecated_kwarg -def get_docstring(filename, fragment_loader, verbose=False, ignore_errors=False, collection_name=None, is_module=None, plugin_type=None): +def get_docstring(filename, fragment_loader, verbose=False, ignore_errors=False, collection_name=None, is_module=Sentinel, plugin_type=None): """ DOCUMENTATION can be extended using documentation fragments loaded by the PluginLoader from the doc_fragments plugins. """ + if is_module is Sentinel: + is_module = None + else: + display.deprecated("is_module is deprecated, pass plugin_type='module' instead", version='2.19') if is_module is None: if plugin_type is None: