1
0
Fork 0

improved the acess for special attributes

Dieser Commit ist enthalten in:
Sebastian Tobie 2023-04-21 17:31:52 +02:00
Ursprung c957e2ddcb
Commit 38beda7ab4
1 geänderte Dateien mit 6 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -30,9 +30,11 @@ class _Type(type):
if key.startswith("_"): if key.startswith("_"):
if key == "__getattr__": if key == "__getattr__":
virtfunc = value virtfunc = value
special[key] = value
elif key == "__dir__": elif key == "__dir__":
virtual = tuple(value(None)) virtual = tuple(value(None))
elif key in ("__doc__",): special[key] = value
elif key in ("__doc__", "__module__", "__qualname__"):
special[key] = value special[key] = value
else: else:
individual[key] = value individual[key] = value
@ -67,7 +69,7 @@ class _Type(type):
return self._vfunc(self, __name) return self._vfunc(self, __name)
if __name in self._individual: if __name in self._individual:
return partial(self._individual[__name], self) return partial(self._individual[__name], self)
raise AttributeError(f"Attribut {__name} not found.") return super().__getattribute__(__name)
def __dir__(self): def __dir__(self):
data = set() data = set()
@ -115,6 +117,7 @@ class Types(metaclass=_Type):
choices: Optional[Sequence] = None, choices: Optional[Sequence] = None,
default: Optional[Any] = None, default: Optional[Any] = None,
): ):
"""Simple wrapper for Ansible {0} argument dict"""
output = _sdict(type=name, required=required) output = _sdict(type=name, required=required)
if choices is not None: if choices is not None:
output["choices"] = choices output["choices"] = choices
@ -124,4 +127,5 @@ class Types(metaclass=_Type):
return output return output
argument.__name__ = name argument.__name__ = name
argument.__doc__ = argument.__doc__.format(name)
return argument return argument