Re-sort imports.

This commit is contained in:
Felix Fontein
2025-12-25 21:58:57 +01:00
parent 74e9abf1f6
commit 9cbf9fc6ec
109 changed files with 86 additions and 219 deletions

View File

@@ -16,7 +16,6 @@ from ansible_collections.community.crypto.plugins.module_utils._acme.errors impo
ModuleFailException,
)
if t.TYPE_CHECKING:
from ansible_collections.community.crypto.plugins.module_utils._acme.acme import ( # pragma: no cover
ACMEClient,

View File

@@ -48,7 +48,6 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
get_now_datetime,
)
if t.TYPE_CHECKING:
import http.client # pragma: no cover
import os # pragma: no cover
@@ -810,8 +809,8 @@ def create_backend(
__all__ = (
"ACMEDirectory",
"ACMEClient",
"create_default_argspec",
"ACMEDirectory",
"create_backend",
"create_default_argspec",
)

View File

@@ -54,7 +54,6 @@ from ansible_collections.community.crypto.plugins.module_utils._version import (
LooseVersion,
)
CRYPTOGRAPHY_MINIMAL_VERSION = "1.5"
CRYPTOGRAPHY_ERROR: None | str
@@ -539,9 +538,9 @@ class CryptographyBackend(CryptoBackend):
__all__ = (
"CRYPTOGRAPHY_ERROR",
"CRYPTOGRAPHY_ERROR",
"CRYPTOGRAPHY_MINIMAL_VERSION",
"CRYPTOGRAPHY_ERROR",
"CRYPTOGRAPHY_VERSION",
"CRYPTOGRAPHY_ERROR",
"CryptographyBackend",
)

View File

@@ -38,7 +38,6 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
ensure_utc_timezone,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover

View File

@@ -29,7 +29,6 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
remove_timezone,
)
if t.TYPE_CHECKING:
import os # pragma: no cover

View File

@@ -36,7 +36,6 @@ from ansible_collections.community.crypto.plugins.module_utils._acme.utils impor
pem_to_der,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover

View File

@@ -22,7 +22,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.pem impor
split_pem_list,
)
if t.TYPE_CHECKING:
from ansible_collections.community.crypto.plugins.module_utils._acme.acme import ( # pragma: no cover
ACMEClient,
@@ -129,4 +128,4 @@ class ChainMatcher(metaclass=abc.ABCMeta):
"""
__all__ = ("CertificateChain", "Criterium", "ChainMatcher")
__all__ = ("CertificateChain", "ChainMatcher", "Criterium")

View File

@@ -27,7 +27,6 @@ from ansible_collections.community.crypto.plugins.module_utils._acme.utils impor
nopad_b64,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
@@ -429,11 +428,11 @@ def wait_for_validation(
__all__ = (
"create_key_authorization",
"Authorization",
"Challenge",
"combine_identifier",
"create_key_authorization",
"normalize_combined_identifier",
"split_identifier",
"Challenge",
"Authorization",
"wait_for_validation",
)

View File

@@ -13,7 +13,6 @@ from http.client import responses as http_responses
from ansible.module_utils.common.text.converters import to_text
if t.TYPE_CHECKING:
import http.client # pragma: no cover
import urllib.error # pragma: no cover
@@ -185,11 +184,11 @@ class KeyParsingError(ModuleFailException):
__all__ = (
"format_http_status",
"format_error_problem",
"ModuleFailException",
"ACMEProtocolException",
"BackendException",
"NetworkException",
"KeyParsingError",
"ModuleFailException",
"NetworkException",
"format_error_problem",
"format_http_status",
)

View File

@@ -19,7 +19,6 @@ from ansible_collections.community.crypto.plugins.module_utils._acme.errors impo
ModuleFailException,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover

View File

@@ -24,7 +24,6 @@ from ansible_collections.community.crypto.plugins.module_utils._acme.utils impor
nopad_b64,
)
if t.TYPE_CHECKING:
from ansible_collections.community.crypto.plugins.module_utils._acme.acme import ( # pragma: no cover
ACMEClient,

View File

@@ -28,7 +28,6 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
get_now_datetime,
)
if t.TYPE_CHECKING:
from ansible_collections.community.crypto.plugins.module_utils._acme.backends import ( # pragma: no cover
CertificateInformation,
@@ -165,10 +164,10 @@ def compute_cert_id(
__all__ = (
"nopad_b64",
"compute_cert_id",
"der_to_pem",
"nopad_b64",
"parse_retry_after",
"pem_to_der",
"process_links",
"parse_retry_after",
"compute_cert_id",
)

View File

@@ -11,7 +11,6 @@ import typing as t
from ansible.module_utils.basic import AnsibleModule
_T = t.TypeVar("_T")

View File

@@ -12,7 +12,6 @@ import re
from ansible.module_utils.common.text.converters import to_bytes
# An ASN.1 serialized as a string in the OpenSSL format:
# [modifier,]type[:value]
#
@@ -173,4 +172,4 @@ def pack_asn1(
return bytes(b_asn1_data) + b_data
__all__ = ("TagClass", "TagNumber", "serialize_asn1_string_as_der", "pack_asn1")
__all__ = ("TagClass", "TagNumber", "pack_asn1", "serialize_asn1_string_as_der")

View File

@@ -33,7 +33,6 @@ from __future__ import annotations
import typing as t
# WARNING: this function no longer works with cryptography 35.0.0 and newer!
# It must **ONLY** be used in compatibility code for older
# cryptography versions!

View File

@@ -11,7 +11,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto._objects_
OID_MAP,
)
OID_LOOKUP: dict[str, str] = {}
NORMALIZE_NAMES: dict[str, str] = {}
NORMALIZE_NAMES_SHORT: dict[str, str] = {}
@@ -35,4 +34,4 @@ for alias, original in [("userID", "userId")]:
OID_LOOKUP[alias] = OID_LOOKUP[original]
__all__ = ("OID_LOOKUP", "NORMALIZE_NAMES", "NORMALIZE_NAMES_SHORT")
__all__ = ("NORMALIZE_NAMES", "NORMALIZE_NAMES_SHORT", "OID_LOOKUP")

View File

@@ -19,7 +19,6 @@
from __future__ import annotations
OID_MAP = {
"0": ("itu-t", "ITU-T", "ccitt"),
"0.3.4401.5": ("ntt-ds",),

View File

@@ -8,7 +8,6 @@
from __future__ import annotations
try:
import cryptography # noqa: F401, pylint: disable=unused-import
@@ -26,4 +25,4 @@ class OpenSSLBadPassphraseError(OpenSSLObjectError):
pass
__all__ = ("HAS_CRYPTOGRAPHY", "OpenSSLObjectError", "OpenSSLBadPassphraseError")
__all__ = ("HAS_CRYPTOGRAPHY", "OpenSSLBadPassphraseError", "OpenSSLObjectError")

View File

@@ -13,7 +13,6 @@ from ansible_collections.community.crypto.plugins.module_utils._version import (
LooseVersion as _LooseVersion,
)
try:
import cryptography
from cryptography import x509
@@ -32,7 +31,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.cryptogra
cryptography_decode_name,
)
if t.TYPE_CHECKING:
import datetime # pragma: no cover
@@ -200,11 +198,11 @@ __all__ = (
"cryptography_decode_revoked_certificate",
"cryptography_dump_revoked",
"cryptography_get_signature_algorithm_oid_from_crl",
"get_next_update",
"get_last_update",
"get_revocation_date",
"get_invalidity_date",
"set_next_update",
"get_last_update",
"get_next_update",
"get_revocation_date",
"set_last_update",
"set_next_update",
"set_revocation_date",
)

View File

@@ -28,7 +28,6 @@ from ansible_collections.community.crypto.plugins.module_utils._version import (
LooseVersion,
)
try:
import cryptography
from cryptography import x509
@@ -86,7 +85,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.basic imp
OpenSSLObjectError,
)
if t.TYPE_CHECKING:
import datetime # pragma: no cover
@@ -1108,27 +1106,27 @@ def is_potential_certificate_issuer_public_key(
__all__ = (
"CRYPTOGRAPHY_TIMEZONE",
"cryptography_compare_private_keys",
"cryptography_compare_public_keys",
"cryptography_decode_name",
"cryptography_get_basic_constraints",
"cryptography_get_extensions_from_cert",
"cryptography_get_extensions_from_csr",
"cryptography_get_name",
"cryptography_key_needs_digest_for_signing",
"cryptography_name_to_oid",
"cryptography_oid_to_name",
"cryptography_parse_relative_distinguished_name",
"cryptography_get_name",
"cryptography_decode_name",
"cryptography_parse_key_usage_params",
"cryptography_get_basic_constraints",
"cryptography_key_needs_digest_for_signing",
"cryptography_compare_public_keys",
"cryptography_compare_private_keys",
"parse_pkcs12",
"cryptography_verify_signature",
"cryptography_parse_relative_distinguished_name",
"cryptography_verify_certificate_signature",
"cryptography_verify_signature",
"get_not_valid_after",
"get_not_valid_before",
"is_potential_certificate_issuer_private_key",
"is_potential_certificate_issuer_public_key",
"is_potential_certificate_private_key",
"is_potential_certificate_public_key",
"parse_pkcs12",
"set_not_valid_after",
"set_not_valid_before",
"is_potential_certificate_private_key",
"is_potential_certificate_issuer_private_key",
"is_potential_certificate_public_key",
"is_potential_certificate_issuer_public_key",
)

View File

@@ -160,11 +160,11 @@ def convert_bytes_to_int(data: bytes) -> int:
__all__ = (
"binary_exp_mod",
"simple_gcd",
"quick_is_not_prime",
"count_bytes",
"count_bits",
"convert_bytes_to_int",
"convert_int_to_bytes",
"convert_int_to_hex",
"convert_bytes_to_int",
"count_bits",
"count_bytes",
"quick_is_not_prime",
"simple_gcd",
)

View File

@@ -36,7 +36,6 @@ from ansible_collections.community.crypto.plugins.module_utils._cryptography_dep
assert_required_cryptography_version,
)
if t.TYPE_CHECKING:
import datetime # pragma: no cover
@@ -416,8 +415,8 @@ def get_certificate_argument_spec() -> ArgumentSpec:
__all__ = (
"CertificateError",
"CertificateBackend",
"CertificateError",
"CertificateProvider",
"get_certificate_argument_spec",
)

View File

@@ -21,7 +21,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.module_ba
CertificateProvider,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover

View File

@@ -37,7 +37,6 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
get_now_datetime,
)
if t.TYPE_CHECKING:
import datetime # pragma: no cover

View File

@@ -40,7 +40,6 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
get_relative_time_option,
)
if t.TYPE_CHECKING:
import datetime # pragma: no cover

View File

@@ -34,7 +34,6 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
get_relative_time_option,
)
if t.TYPE_CHECKING:
import datetime # pragma: no cover

View File

@@ -26,7 +26,6 @@ from ansible_collections.community.crypto.plugins.module_utils._cryptography_dep
assert_required_cryptography_version,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover

View File

@@ -47,7 +47,6 @@ from ansible_collections.community.crypto.plugins.module_utils._cryptography_dep
assert_required_cryptography_version,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
from cryptography.hazmat.primitives.asymmetric.types import ( # pragma: no cover
@@ -926,8 +925,8 @@ def get_csr_argument_spec() -> ArgumentSpec:
__all__ = (
"CertificateSigningRequestError",
"CertificateSigningRequestBackend",
"select_backend",
"CertificateSigningRequestError",
"get_csr_argument_spec",
"select_backend",
)

View File

@@ -30,7 +30,6 @@ from ansible_collections.community.crypto.plugins.module_utils._cryptography_dep
assert_required_cryptography_version,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
from cryptography.hazmat.primitives.asymmetric.types import ( # pragma: no cover

View File

@@ -36,7 +36,6 @@ from ansible_collections.community.crypto.plugins.module_utils._cryptography_dep
assert_required_cryptography_version,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
from cryptography.hazmat.primitives.asymmetric.types import ( # pragma: no cover
@@ -655,8 +654,8 @@ def get_privatekey_argument_spec() -> ArgumentSpec:
__all__ = (
"PrivateKeyError",
"PrivateKeyBackend",
"select_backend",
"PrivateKeyError",
"get_privatekey_argument_spec",
"select_backend",
)

View File

@@ -30,7 +30,6 @@ from ansible_collections.community.crypto.plugins.module_utils._cryptography_dep
)
from ansible_collections.community.crypto.plugins.module_utils._io import load_file
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
from cryptography.hazmat.primitives.asymmetric.types import ( # pragma: no cover
@@ -287,8 +286,8 @@ def get_privatekey_argument_spec() -> ArgumentSpec:
__all__ = (
"PrivateKeyError",
"PrivateKeyConvertBackend",
"select_backend",
"PrivateKeyError",
"get_privatekey_argument_spec",
"select_backend",
)

View File

@@ -33,7 +33,6 @@ from ansible_collections.community.crypto.plugins.module_utils._cryptography_dep
assert_required_cryptography_version,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
from cryptography.hazmat.primitives.asymmetric.types import ( # pragma: no cover
@@ -336,8 +335,8 @@ def select_backend(
__all__ = (
"PrivateKeyConsistencyError",
"PrivateKeyParseError",
"PrivateKeyInfoRetrieval",
"PrivateKeyParseError",
"get_privatekey_info",
"select_backend",
)

View File

@@ -21,7 +21,6 @@ from ansible_collections.community.crypto.plugins.module_utils._cryptography_dep
assert_required_cryptography_version,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
from cryptography.hazmat.primitives.asymmetric.types import ( # pragma: no cover
@@ -178,8 +177,8 @@ def select_backend(
__all__ = (
"PublicKeyParseError",
"PublicKeyInfoRetrieval",
"PublicKeyParseError",
"get_publickey_info",
"select_backend",
)

View File

@@ -9,7 +9,6 @@ from __future__ import annotations
import typing as t
PEM_START = "-----BEGIN "
PEM_END_START = "-----END "
PEM_END = "-----"
@@ -128,14 +127,14 @@ def extract_pem(content: str, *, strict: bool = False) -> tuple[str, str]:
__all__ = (
"PEM_START",
"PEM_END_START",
"PEM_END",
"PKCS8_PRIVATEKEY_NAMES",
"PEM_END_START",
"PEM_START",
"PKCS1_PRIVATEKEY_SUFFIX",
"PKCS8_PRIVATEKEY_NAMES",
"extract_first_pem",
"extract_pem",
"identify_pem_format",
"identify_private_key_format",
"split_pem_list",
"extract_first_pem",
"extract_pem",
)

View File

@@ -23,7 +23,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.pem impor
identify_pem_format,
)
try:
from cryptography import x509
from cryptography.exceptions import UnsupportedAlgorithm
@@ -38,7 +37,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.basic imp
OpenSSLObjectError,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
from cryptography.hazmat.primitives.asymmetric.types import ( # pragma: no cover
@@ -467,17 +465,17 @@ class OpenSSLObject(metaclass=abc.ABCMeta):
__all__ = (
"OpenSSLObject",
"get_fingerprint",
"get_fingerprint_of_bytes",
"get_fingerprint_of_privatekey",
"get_fingerprint",
"load_privatekey",
"load_certificate_privatekey",
"load_certificate_issuer_privatekey",
"load_publickey",
"load_certificate",
"load_certificate_issuer_privatekey",
"load_certificate_privatekey",
"load_certificate_request",
"load_privatekey",
"load_publickey",
"parse_name_field",
"parse_ordered_name_field",
"select_message_digest",
"OpenSSLObject",
)

View File

@@ -22,7 +22,6 @@ from ansible_collections.community.crypto.plugins.module_utils._version import (
LooseVersion,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover

View File

@@ -82,7 +82,7 @@ def get_fingerprint_from_bytes(*, gpg_runner: GPGRunner, content: bytes) -> str:
__all__ = (
"GPGError",
"GPGRunner",
"get_fingerprint_from_stdout",
"get_fingerprint_from_file",
"get_fingerprint_from_bytes",
"get_fingerprint_from_file",
"get_fingerprint_from_stdout",
)

View File

@@ -12,7 +12,6 @@ import os
import tempfile
import typing as t
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover

View File

@@ -18,7 +18,6 @@ from ansible_collections.community.crypto.plugins.module_utils._openssh.utils im
parse_openssh_version,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
@@ -485,11 +484,11 @@ def parse_private_key_format(
__all__ = (
"restore_on_failure",
"safe_atomic_move",
"OpensshModule",
"KeygenCommand",
"OpensshModule",
"PrivateKey",
"PublicKey",
"parse_private_key_format",
"restore_on_failure",
"safe_atomic_move",
)

View File

@@ -43,7 +43,6 @@ from ansible_collections.community.crypto.plugins.module_utils._version import (
LooseVersion,
)
if t.TYPE_CHECKING:
from ansible.module_utils.basic import AnsibleModule # pragma: no cover

View File

@@ -30,7 +30,6 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
convert_relative_to_datetime,
)
if t.TYPE_CHECKING:
from ansible_collections.community.crypto.plugins.module_utils._openssh.cryptography import ( # pragma: no cover
KeyType,
@@ -840,14 +839,14 @@ def parse_option_list(
__all__ = (
"OpensshCertificateTimeParameters",
"OpensshCertificateOption",
"OpensshCertificate",
"OpensshCertificateInfo",
"OpensshRSACertificateInfo",
"OpensshCertificateOption",
"OpensshCertificateTimeParameters",
"OpensshDSACertificateInfo",
"OpensshECDSACertificateInfo",
"OpensshED25519CertificateInfo",
"OpensshCertificate",
"OpensshRSACertificateInfo",
"apply_directives",
"default_options",
"fingerprint",

View File

@@ -13,7 +13,6 @@ from base64 import b64decode, b64encode
from getpass import getuser
from socket import gethostname
try:
from cryptography import __version__ as CRYPTOGRAPHY_VERSION
from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm
@@ -73,7 +72,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.cryptogra
is_potential_certificate_issuer_private_key,
)
if t.TYPE_CHECKING:
KeyFormat = t.Literal["SSH", "PKCS8", "PKCS1"] # pragma: no cover
KeySerializationFormat = t.Literal["PEM", "DER", "SSH"] # pragma: no cover
@@ -815,27 +813,27 @@ def calculate_fingerprint(openssh_publickey: bytes) -> str:
__all__ = (
"HAS_OPENSSH_SUPPORT",
"CRYPTOGRAPHY_VERSION",
"OpenSSHError",
"HAS_OPENSSH_SUPPORT",
"AsymmetricKeypair",
"InvalidAlgorithmError",
"InvalidCommentError",
"InvalidDataError",
"InvalidPrivateKeyFileError",
"InvalidPublicKeyFileError",
"InvalidKeyFormatError",
"InvalidKeySizeError",
"InvalidKeyTypeError",
"InvalidPassphraseError",
"InvalidPrivateKeyFileError",
"InvalidPublicKeyFileError",
"InvalidSignatureError",
"AsymmetricKeypair",
"OpenSSHError",
"OpensshKeypair",
"calculate_fingerprint",
"compare_encryption_algorithms",
"compare_publickeys",
"extract_comment",
"get_encryption_algorithm",
"load_privatekey",
"load_publickey",
"compare_publickeys",
"compare_encryption_algorithms",
"get_encryption_algorithm",
"validate_comment",
"extract_comment",
"calculate_fingerprint",
)

View File

@@ -14,7 +14,6 @@ import typing as t
from contextlib import contextmanager
from struct import Struct
# Protocol References
# -------------------
# https://datatracker.ietf.org/doc/html/rfc4251
@@ -351,10 +350,10 @@ class _OpensshWriter:
__all__ = (
"OpensshParser",
"any_in",
"file_mode",
"parse_openssh_version",
"secure_open",
"secure_write",
"OpensshParser",
)

View File

@@ -16,7 +16,6 @@ from ansible_collections.community.crypto.plugins.module_utils._crypto.basic imp
OpenSSLObjectError,
)
UTC = datetime.timezone.utc
@@ -160,12 +159,12 @@ def get_relative_time_option(
__all__ = (
"get_now_datetime",
"ensure_utc_timezone",
"remove_timezone",
"add_or_remove_timezone",
"get_epoch_seconds",
"from_epoch_seconds",
"convert_relative_to_datetime",
"ensure_utc_timezone",
"from_epoch_seconds",
"get_epoch_seconds",
"get_now_datetime",
"get_relative_time_option",
"remove_timezone",
)

View File

@@ -11,5 +11,4 @@ from __future__ import annotations
from ansible.module_utils.compat.version import LooseVersion
__all__ = ("LooseVersion",)