Commits vergleichen

...

4 Commits

Autor SHA1 Nachricht Datum
144ffc72a5 some clean up of the code 2025-03-14 08:35:47 +01:00
c8d7d4e286 fixed an typing error 2025-03-14 08:35:28 +01:00
9d18ea533e removed display 2024-03-16 21:28:31 +01:00
f351bb6fb6 fixed typo 2024-03-16 21:28:18 +01:00
2 geänderte Dateien mit 9 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -23,9 +23,9 @@ def wrap_func(func, **updates):
def wrapper(*args, **kwargs):
return func(*args, **kwargs)
attrs = frozenset(
('__module__', '__name__', '__qualname__', '__doc__', '__annotations__', '__type_params__')
) - frozenset(updates.keys())
attrs = set(('__module__', '__name__', '__qualname__', '__doc__', '__annotations__', '__type_params__')).difference(
updates.keys()
)
for attr in attrs:
try:
value = getattr(func, attr)
@ -90,6 +90,7 @@ class meta(type):
class Types(metaclass=meta):
@staticmethod
def list( # type: ignore[misc]
elements: Union[Type[object], str, AnsibleParameter],
required: bool = False,
@ -109,7 +110,7 @@ class Types(metaclass=meta):
option["elements"] = elements["type"]
if elements["type"] == "dict":
option["options"] = dict()
for name, value in elements["option"].items():
for name, value in elements["options"].items():
option["options"][name] = value
if "description" not in option["options"][name]:
warnings.warn( # pragma: nocover
@ -120,6 +121,7 @@ class Types(metaclass=meta):
option["description"] = help.split("\n")
return option
@staticmethod
def dict(required: bool = False, help: Optional[str] = None, **options: AnsibleParameter) -> AnsibleParameter: # type: ignore[misc]
"""Wrapper for the Ansible dict type
@ -154,6 +156,7 @@ def modspec(
supports_check_mode: bool = False,
add_file_common_args: bool = False,
) -> Dict[str, Any]: # pragma: nocover
"""Wrapper to properly Type the module specs"""
return dict(
argument_spec=argument_spec,
mutually_exclusive=mutually_exclusive,

Datei anzeigen

@ -1,7 +1,6 @@
import pathlib
from copy import deepcopy
from typing import Any, Callable, ClassVar, Dict, NoReturn, Optional, Type, TypeVar, Union, overload, TypedDict
from ansible.utils.display import Display
import ansible.module_utils.basic as basic
@ -21,8 +20,8 @@ T = TypeVar("T")
class TypedDiff(TypedDict):
before: str
after: str
before_header: Optional[str] = None
after_header: Optional[str] = None
before_header: Optional[str]
after_header: Optional[str]
def docify(input: Union[dict, AnsibleParameter]) -> dict:
@ -63,8 +62,6 @@ class AnsibleModule(object):
module_spec: ClassVar[dict]
#: This is set by classes that define common things for their subclasses, like behaviour of the run and check methods. This is used by `SystemdUnitModule`
_common_args: ClassVar[dict[str, Any]] = dict()
#: For log messages
display: Display
@property
def params(self) -> Dict[str, Any]:
@ -80,7 +77,6 @@ class AnsibleModule(object):
specs["argument_spec"].update(modspec["argument_spec"])
del modspec["argument_spec"]
specs.update(modspec)
self.display = Display()
self.module = basic.AnsibleModule(**specs)
self.tmpdir = pathlib.Path(self.module.tmpdir)