Simplify deprecation mechanism

Co-Authored-By: Sloane Hertel <19572925+s-hertel@users.noreply.github.com>
Co-Authored-By: Matt Martz <matt@sivel.net>
pull/82192/head
JustinWayland 1 year ago
parent 1f79acee46
commit 2e018bb064

@ -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:

Loading…
Cancel
Save