Code refactoring (#889)

* Add __all__ to all module and plugin utils.

* Convert quite a few positional args to keyword args.

* Avoid Python 3.8+ syntax.
This commit is contained in:
Felix Fontein
2025-05-16 06:55:57 +02:00
committed by GitHub
parent a5a4e022ba
commit 44bcc8cebc
101 changed files with 1510 additions and 748 deletions

View File

@@ -59,7 +59,7 @@ def gpg_fingerprint(input: str | bytes) -> str:
)
try:
gpg = PluginGPGRunner()
return get_fingerprint_from_bytes(gpg, to_bytes(input))
return get_fingerprint_from_bytes(gpg_runner=gpg, content=to_bytes(input))
except GPGError as exc:
raise AnsibleFilterError(str(exc))

View File

@@ -309,7 +309,9 @@ def openssl_csr_info_filter(
module = FilterModuleMock({"name_encoding": name_encoding})
try:
return get_csr_info(module, content=to_bytes(data), validate_signature=True)
return get_csr_info(
module=module, content=to_bytes(data), validate_signature=True
)
except OpenSSLObjectError as exc:
raise AnsibleFilterError(str(exc))

View File

@@ -184,7 +184,7 @@ def openssl_privatekey_info_filter(
module = FilterModuleMock({})
try:
result = get_privatekey_info(
module,
module=module,
content=to_bytes(data),
passphrase=to_text(passphrase) if passphrase is not None else None,
return_private_key_data=return_private_key_data,

View File

@@ -148,7 +148,7 @@ def openssl_publickey_info_filter(data: str | bytes) -> dict[str, t.Any]:
module = FilterModuleMock({})
try:
return get_publickey_info(module, content=to_bytes(data))
return get_publickey_info(module=module, content=to_bytes(data))
except PublicKeyParseError as exc:
raise AnsibleFilterError(exc.error_message)
except OpenSSLObjectError as exc:

View File

@@ -343,7 +343,7 @@ def x509_certificate_info_filter(
module = FilterModuleMock({"name_encoding": name_encoding})
try:
return get_certificate_info(module, content=to_bytes(data))
return get_certificate_info(module=module, content=to_bytes(data))
except OpenSSLObjectError as exc:
raise AnsibleFilterError(str(exc))

View File

@@ -207,7 +207,7 @@ def x509_crl_info_filter(
module = FilterModuleMock({"name_encoding": name_encoding})
try:
return get_crl_info(
module,
module=module,
content=data_bytes,
list_revoked_certificates=list_revoked_certificates,
)