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

@@ -99,8 +99,7 @@ class ACMEAccount:
and allow_creation
):
raise ModuleFailException(
"To create an account, an external account binding must be specified. "
"Use the acme_account module with the external_account_binding option."
"To create an account, an external account binding must be specified. Use the acme_account module with the external_account_binding option."
)
result, info = self.client.send_signed_request(

View File

@@ -108,8 +108,7 @@ class CryptographyChainMatcher(ChainMatcher):
)
else:
module.warn(
f"Criterium {criterium_idx} in select_chain has invalid {name} value. "
"Ignoring criterium."
f"Criterium {criterium_idx} in select_chain has invalid {name} value. Ignoring criterium."
)
return None

View File

@@ -191,8 +191,7 @@ class ACMECertificateClient:
if bad_authzs:
bad_authzs_str = ", ".join(sorted(bad_authzs))
raise ModuleFailException(
"Some of the authorizations for the order are in a bad state, so the order"
f" can no longer be satisfied: {bad_authzs_str}",
f"Some of the authorizations for the order are in a bad state, so the order can no longer be satisfied: {bad_authzs_str}",
)
def collect_invalid_authzs(self, order: Order) -> list[Authorization]:

View File

@@ -486,7 +486,7 @@ def _adjust_idn_email(
idx = value.find("@")
if idx < 0:
return value
return f"{value[:idx]}@{_adjust_idn(value[idx + 1:], idn_rewrite=idn_rewrite)}"
return f"{value[:idx]}@{_adjust_idn(value[idx + 1 :], idn_rewrite=idn_rewrite)}"
def _adjust_idn_url(

View File

@@ -525,8 +525,7 @@ class CertificateSigningRequestCryptographyBackend(CertificateSigningRequestBack
if self.using_common_name_for_san:
self.module.fail_json(
msg=msg
+ "This is probably caused because the Common Name is used as a SAN."
" Specifying use_common_name_for_san=false might fix this."
+ "This is probably caused because the Common Name is used as a SAN. Specifying use_common_name_for_san=false might fix this."
)
self.module.fail_json(
msg=msg

View File

@@ -312,7 +312,6 @@ class _Curve:
# Implementation with using cryptography
class PrivateKeyCryptographyBackend(PrivateKeyBackend):
def _add_curve(
self,
name: str,

View File

@@ -283,10 +283,7 @@ class PrivateKeyInfoRetrieval(metaclass=abc.ABCMeta):
)
if result["key_is_consistent"] is False:
# Only fail when it is False, to avoid to fail on None (which means "we do not know")
msg = (
"Private key is not consistent! (See "
"https://blog.hboeck.de/archives/888-How-I-tricked-Symantec-with-a-Fake-Private-Key.html)"
)
msg = "Private key is not consistent! (See https://blog.hboeck.de/archives/888-How-I-tricked-Symantec-with-a-Fake-Private-Key.html)"
raise PrivateKeyConsistencyError(msg, result=result)
return result

View File

@@ -381,7 +381,6 @@ def select_message_digest(
class OpenSSLObject(metaclass=abc.ABCMeta):
def __init__(self, *, path: str, state: str, force: bool, check_mode: bool) -> None:
self.path = path
self.state = state

View File

@@ -52,7 +52,6 @@ if t.TYPE_CHECKING:
class KeypairBackend(OpensshModule, metaclass=abc.ABCMeta):
def __init__(self, *, module: AnsibleModule) -> None:
super().__init__(module=module)
@@ -567,8 +566,7 @@ def select_backend(
else:
module.fail_json(
msg=(
"Cannot find either the OpenSSH binary in the PATH "
f"or cryptography >= {COLLECTION_MINIMUM_CRYPTOGRAPHY_VERSION} installed on this system"
f"Cannot find either the OpenSSH binary in the PATH or cryptography >= {COLLECTION_MINIMUM_CRYPTOGRAPHY_VERSION} installed on this system"
)
)

View File

@@ -779,8 +779,7 @@ def get_option_type(name: str) -> t.Literal["critical", "extension"]:
if name in _EXTENSIONS:
return "extension"
raise ValueError(
f"{name} is not a valid option. "
"Custom options must start with 'critical:' or 'extension:' to indicate type"
f"{name} is not a valid option. Custom options must start with 'critical:' or 'extension:' to indicate type"
)

View File

@@ -370,7 +370,8 @@ class AsymmetricKeypair:
try:
return self.__privatekey.sign(
data, **_ALGORITHM_PARAMETERS[self.__keytype]["signer_params"] # type: ignore
data,
**_ALGORITHM_PARAMETERS[self.__keytype]["signer_params"], # type: ignore
)
except TypeError as e:
raise InvalidDataError(e) from e
@@ -788,7 +789,6 @@ def validate_comment(comment: str) -> None:
def extract_comment(path: str | os.PathLike) -> str:
if not os.path.exists(path):
raise InvalidPublicKeyFileError(f"No file was found at {path}")