From 38beda7ab461e513441b488d6dca3e354f5bb1fa Mon Sep 17 00:00:00 2001 From: Sebastian Tobie Date: Fri, 21 Apr 2023 17:31:52 +0200 Subject: [PATCH] improved the acess for special attributes --- plugins/module_utils/generic.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/module_utils/generic.py b/plugins/module_utils/generic.py index 79fa21e..8024e3a 100644 --- a/plugins/module_utils/generic.py +++ b/plugins/module_utils/generic.py @@ -30,9 +30,11 @@ class _Type(type): if key.startswith("_"): if key == "__getattr__": virtfunc = value + special[key] = value elif key == "__dir__": virtual = tuple(value(None)) - elif key in ("__doc__",): + special[key] = value + elif key in ("__doc__", "__module__", "__qualname__"): special[key] = value else: individual[key] = value @@ -67,7 +69,7 @@ class _Type(type): return self._vfunc(self, __name) if __name in self._individual: return partial(self._individual[__name], self) - raise AttributeError(f"Attribut {__name} not found.") + return super().__getattribute__(__name) def __dir__(self): data = set() @@ -115,6 +117,7 @@ class Types(metaclass=_Type): choices: Optional[Sequence] = None, default: Optional[Any] = None, ): + """Simple wrapper for Ansible {0} argument dict""" output = _sdict(type=name, required=required) if choices is not None: output["choices"] = choices @@ -124,4 +127,5 @@ class Types(metaclass=_Type): return output argument.__name__ = name + argument.__doc__ = argument.__doc__.format(name) return argument