Use ruff format, and then undo most changes with black and isort. (#903)

This commit is contained in:
Felix Fontein
2025-05-24 08:30:31 +02:00
committed by GitHub
parent f3db4eeea5
commit b8adc3b241
34 changed files with 23 additions and 63 deletions

View File

@@ -310,8 +310,7 @@ def main() -> t.NoReturn:
if timestamp < now:
complete(
True,
msg=f"The remaining percentage {module.params['remaining_percentage'] * 100}%"
f" of the certificate's lifespan was reached on {timestamp}",
msg=f"The remaining percentage {module.params['remaining_percentage'] * 100}% of the certificate's lifespan was reached on {timestamp}",
)
complete(False)

View File

@@ -368,8 +368,7 @@ def main() -> t.NoReturn:
if not is_parent(module, chain[i - 1], parent):
module.fail_json(
msg=(
f"Cannot verify input chain: certificate #{i + 1}: {format_cert(parent)} is not issuer "
f"of certificate #{i}: {format_cert(chain[i - 1])}"
f"Cannot verify input chain: certificate #{i + 1}: {format_cert(parent)} is not issuer of certificate #{i}: {format_cert(chain[i - 1])}"
)
)

View File

@@ -474,7 +474,6 @@ def wipe_luks_headers(device: str) -> None:
class Handler:
def __init__(self, module: AnsibleModule) -> None:
self._module = module
self._lsblk_bin = self._module.get_bin_path("lsblk", True)
@@ -534,7 +533,6 @@ class Handler:
class CryptHandler(Handler):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(module)
self._cryptsetup_bin = self._module.get_bin_path("cryptsetup", True)
@@ -807,8 +805,7 @@ class CryptHandler(Handler):
keyslot_area = False
if keyslot_count < 2:
self._module.fail_json(
msg=f"LUKS device {device} has less than two active keyslots. "
"To be able to remove a key, please set `force_remove_last_key` to `true`."
msg=f"LUKS device {device} has less than two active keyslots. To be able to remove a key, please set `force_remove_last_key` to `true`."
)
if keyslot is None:
@@ -867,7 +864,6 @@ class CryptHandler(Handler):
class ConditionsHandler(Handler):
def __init__(self, module: AnsibleModule, crypthandler: CryptHandler) -> None:
super().__init__(module)
self._crypthandler = crypthandler
@@ -988,7 +984,7 @@ class ConditionsHandler(Handler):
if self._module.params["state"] == "absent":
self._module.fail_json(
msg="Contradiction in setup: Asking to " "add a key to absent LUKS."
msg="Contradiction in setup: Asking to add a key to absent LUKS."
)
key_present = self._crypthandler.luks_test_key(
@@ -1021,8 +1017,7 @@ class ConditionsHandler(Handler):
if self._module.params["state"] == "absent":
self._module.fail_json(
msg="Contradiction in setup: Asking to "
"remove a key from absent LUKS."
msg="Contradiction in setup: Asking to remove a key from absent LUKS."
)
if self._module.params["remove_keyslot"] is not None:

View File

@@ -207,7 +207,6 @@ from ansible_collections.community.crypto.plugins.module_utils._openssh.backends
def main() -> t.NoReturn:
module = AnsibleModule(
argument_spec={
"state": {

View File

@@ -265,7 +265,6 @@ if t.TYPE_CHECKING:
class CertificateSigningRequestModule(OpenSSLObject):
def __init__(
self, module: AnsibleModule, module_backend: CertificateSigningRequestBackend
) -> None:

View File

@@ -173,7 +173,6 @@ class DHParameterError(Exception):
class DHParameterBase:
def __init__(self, module: AnsibleModule) -> None:
self.state: t.Literal["absent", "present"] = module.params["state"]
self.path: str = module.params["path"]
@@ -250,7 +249,6 @@ class DHParameterBase:
class DHParameterAbsent(DHParameterBase):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(module)
@@ -263,7 +261,6 @@ class DHParameterAbsent(DHParameterBase):
class DHParameterOpenSSL(DHParameterBase):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(module)
self.openssl_bin = module.get_bin_path("openssl", True)
@@ -318,7 +315,6 @@ class DHParameterOpenSSL(DHParameterBase):
class DHParameterCryptography(DHParameterBase):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(module)
@@ -408,8 +404,7 @@ def main() -> t.NoReturn:
if backend == "auto":
module.fail_json(
msg=(
f"Cannot detect either the required Python library cryptography (>= {MINIMAL_CRYPTOGRAPHY_VERSION}) "
"or the OpenSSL binary openssl"
f"Cannot detect either the required Python library cryptography (>= {MINIMAL_CRYPTOGRAPHY_VERSION}) or the OpenSSL binary openssl"
)
)

View File

@@ -599,7 +599,9 @@ class Pkcs(OpenSSLObject):
self.backup_file = module.backup_local(self.path)
super().remove(module)
def parse(self) -> tuple[
def parse(
self,
) -> tuple[
bytes | None,
bytes | None,
list[bytes],

View File

@@ -181,7 +181,6 @@ if t.TYPE_CHECKING:
class PrivateKeyModule(OpenSSLObject):
def __init__(
self, module: AnsibleModule, module_backend: PrivateKeyBackend
) -> None:
@@ -255,7 +254,6 @@ class PrivateKeyModule(OpenSSLObject):
def main() -> t.NoReturn:
argument_spec = get_privatekey_argument_spec()
argument_spec.argument_spec.update(
{

View File

@@ -142,7 +142,6 @@ class PrivateKeyConvertModule(OpenSSLObject):
def main() -> t.NoReturn:
argument_spec = get_privatekey_argument_spec()
argument_spec.argument_spec.update(
{

View File

@@ -246,7 +246,8 @@ def main() -> t.NoReturn:
data = f.read()
except (IOError, OSError) as e:
module.fail_json(
msg=f"Error while reading private key file from disk: {e}", **result # type: ignore
msg=f"Error while reading private key file from disk: {e}",
**result, # type: ignore
)
result["can_load_key"] = True

View File

@@ -231,7 +231,6 @@ class PublicKeyError(OpenSSLObjectError):
class PublicKey(OpenSSLObject):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(
path=module.params["path"],
@@ -415,7 +414,6 @@ class PublicKey(OpenSSLObject):
def main() -> t.NoReturn:
module = AnsibleModule(
argument_spec={
"state": {

View File

@@ -194,7 +194,8 @@ def main() -> t.NoReturn:
data = f.read()
except (IOError, OSError) as e:
module.fail_json(
msg=f"Error while reading public key file from disk: {e}", **result # type: ignore
msg=f"Error while reading public key file from disk: {e}",
**result, # type: ignore
)
module_backend = select_backend(module=module, content=data)

View File

@@ -132,7 +132,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.support i
class SignatureBase(OpenSSLObject):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(
path=module.params["path"],
@@ -161,7 +160,6 @@ class SignatureBase(OpenSSLObject):
# Implementation with using cryptography
class SignatureCryptography(SignatureBase):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(module)

View File

@@ -121,7 +121,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.support i
class SignatureInfoBase(OpenSSLObject):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(
path=module.params["path"],
@@ -150,7 +149,6 @@ class SignatureInfoBase(OpenSSLObject):
# Implementation with using cryptography
class SignatureInfoCryptography(SignatureInfoBase):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(module)

View File

@@ -505,7 +505,6 @@ class CRLError(OpenSSLObjectError):
class CRL(OpenSSLObject):
def __init__(self, module: AnsibleModule) -> None:
super().__init__(
path=module.params["path"],