diff --git a/plugins/module_utils/_acme/backend_cryptography.py b/plugins/module_utils/_acme/backend_cryptography.py index a2b789c4..9f563835 100644 --- a/plugins/module_utils/_acme/backend_cryptography.py +++ b/plugins/module_utils/_acme/backend_cryptography.py @@ -57,7 +57,7 @@ from ansible_collections.community.crypto.plugins.module_utils._version import ( CRYPTOGRAPHY_MINIMAL_VERSION = "1.5" -CRYPTOGRAPHY_ERROR = None +CRYPTOGRAPHY_ERROR: None | str try: import cryptography import cryptography.hazmat.backends @@ -71,14 +71,15 @@ try: import cryptography.x509 import cryptography.x509.oid except ImportError: - HAS_CURRENT_CRYPTOGRAPHY = False - CRYPTOGRAPHY_VERSION = None - CRYPTOGRAPHY_ERROR = traceback.format_exc() + HAS_CURRENT_CRYPTOGRAPHY = False # pylint: disable=invalid-name + CRYPTOGRAPHY_VERSION = None # pylint: disable=invalid-name + CRYPTOGRAPHY_ERROR = traceback.format_exc() # pylint: disable=invalid-name else: - CRYPTOGRAPHY_VERSION = cryptography.__version__ + CRYPTOGRAPHY_VERSION = cryptography.__version__ # pylint: disable=invalid-name HAS_CURRENT_CRYPTOGRAPHY = LooseVersion(CRYPTOGRAPHY_VERSION) >= LooseVersion( CRYPTOGRAPHY_MINIMAL_VERSION ) + CRYPTOGRAPHY_ERROR = None # pylint: disable=invalid-name if t.TYPE_CHECKING: import datetime # pragma: no cover diff --git a/plugins/module_utils/_crypto/cryptography_crl.py b/plugins/module_utils/_crypto/cryptography_crl.py index 8821f2ae..2c56219a 100644 --- a/plugins/module_utils/_crypto/cryptography_crl.py +++ b/plugins/module_utils/_crypto/cryptography_crl.py @@ -40,7 +40,7 @@ if t.TYPE_CHECKING: # TODO: once cryptography has a _utc variant of InvalidityDate.invalidity_date, set this # to True and adjust get_invalidity_date() accordingly. # (https://github.com/pyca/cryptography/issues/10818) -CRYPTOGRAPHY_TIMEZONE_INVALIDITY_DATE = False +CRYPTOGRAPHY_TIMEZONE_INVALIDITY_DATE = False # pylint: disable=invalid-name if HAS_CRYPTOGRAPHY: CRYPTOGRAPHY_TIMEZONE_INVALIDITY_DATE = _LooseVersion( cryptography.__version__ diff --git a/plugins/module_utils/_crypto/cryptography_support.py b/plugins/module_utils/_crypto/cryptography_support.py index c65a20b9..1af3bcfb 100644 --- a/plugins/module_utils/_crypto/cryptography_support.py +++ b/plugins/module_utils/_crypto/cryptography_support.py @@ -134,8 +134,8 @@ else: PrivateKeyTypesWOEdwards = None # pylint: disable=invalid-name -CRYPTOGRAPHY_TIMEZONE = False -_CRYPTOGRAPHY_36_0_OR_NEWER = False +CRYPTOGRAPHY_TIMEZONE = False # pylint: disable=invalid-name +_CRYPTOGRAPHY_36_0_OR_NEWER = False # pylint: disable=invalid-name if _HAS_CRYPTOGRAPHY: CRYPTOGRAPHY_TIMEZONE = LooseVersion(cryptography.__version__) >= LooseVersion( "42.0.0" diff --git a/plugins/module_utils/_cryptography_dep.py b/plugins/module_utils/_cryptography_dep.py index 8905855e..35c1d5f3 100644 --- a/plugins/module_utils/_cryptography_dep.py +++ b/plugins/module_utils/_cryptography_dep.py @@ -38,20 +38,21 @@ if t.TYPE_CHECKING: ] # pragma: no cover -_CRYPTOGRAPHY_IMP_ERR: str | None = None -_CRYPTOGRAPHY_FILE: str | None = None +_CRYPTOGRAPHY_IMP_ERR: str | None = None # pylint: disable=invalid-name +_CRYPTOGRAPHY_FILE: str | None = None # pylint: disable=invalid-name try: import cryptography from cryptography import x509 # noqa: F401, pylint: disable=unused-import - CRYPTOGRAPHY_VERSION = LooseVersion(cryptography.__version__) - _CRYPTOGRAPHY_FILE = cryptography.__file__ except ImportError: - _CRYPTOGRAPHY_IMP_ERR = traceback.format_exc() + _CRYPTOGRAPHY_IMP_ERR = traceback.format_exc() # pylint: disable=invalid-name CRYPTOGRAPHY_FOUND = False - CRYPTOGRAPHY_VERSION = LooseVersion("0.0") + CRYPTOGRAPHY_VERSION = LooseVersion("0.0") # pylint: disable=invalid-name else: CRYPTOGRAPHY_FOUND = True + # pylint: disable-next=invalid-name + CRYPTOGRAPHY_VERSION = LooseVersion(cryptography.__version__) + _CRYPTOGRAPHY_FILE = cryptography.__file__ # pylint: disable=invalid-name # Corresponds to the community.crypto.cryptography_dep.minimum doc fragment diff --git a/plugins/modules/crypto_info.py b/plugins/modules/crypto_info.py index a6e8a555..1be49f7f 100644 --- a/plugins/modules/crypto_info.py +++ b/plugins/modules/crypto_info.py @@ -174,12 +174,12 @@ except ImportError: UnsupportedAlgorithm = Exception # type: ignore CryptographyInternalError = Exception # type: ignore HAS_CRYPTOGRAPHY = False - CRYPTOGRAPHY_VERSION = None - CRYPTOGRAPHY_IMP_ERR = traceback.format_exc() + CRYPTOGRAPHY_VERSION = None # pylint: disable=invalid-name + CRYPTOGRAPHY_IMP_ERR = traceback.format_exc() # pylint: disable=invalid-name else: HAS_CRYPTOGRAPHY = True - CRYPTOGRAPHY_VERSION = cryptography.__version__ - CRYPTOGRAPHY_IMP_ERR = None + CRYPTOGRAPHY_VERSION = cryptography.__version__ # pylint: disable=invalid-name + CRYPTOGRAPHY_IMP_ERR = None # pylint: disable=invalid-name CURVES = ( diff --git a/plugins/modules/openssl_pkcs12.py b/plugins/modules/openssl_pkcs12.py index d71513ed..f9a48691 100644 --- a/plugins/modules/openssl_pkcs12.py +++ b/plugins/modules/openssl_pkcs12.py @@ -318,7 +318,7 @@ try: except ImportError: pass -CRYPTOGRAPHY_COMPATIBILITY2022_ERR = None +CRYPTOGRAPHY_COMPATIBILITY2022_ERR: str | None try: import cryptography.x509 from cryptography.hazmat.primitives import hashes @@ -329,9 +329,11 @@ try: PBES.PBESv1SHA1And3KeyTripleDESCBC ).hmac_hash(hashes.SHA1()) except Exception: + # pylint: disable-next=invalid-name CRYPTOGRAPHY_COMPATIBILITY2022_ERR = traceback.format_exc() CRYPTOGRAPHY_HAS_COMPATIBILITY2022 = False else: + CRYPTOGRAPHY_COMPATIBILITY2022_ERR = None # pylint: disable=invalid-name CRYPTOGRAPHY_HAS_COMPATIBILITY2022 = True if t.TYPE_CHECKING: diff --git a/plugins/modules/openssl_signature.py b/plugins/modules/openssl_signature.py index e5ba356d..d7188c72 100644 --- a/plugins/modules/openssl_signature.py +++ b/plugins/modules/openssl_signature.py @@ -117,9 +117,11 @@ try: import cryptography.hazmat.primitives.asymmetric.padding import cryptography.hazmat.primitives.hashes - CRYPTOGRAPHY_VERSION = LooseVersion(cryptography.__version__) except ImportError: - CRYPTOGRAPHY_VERSION = LooseVersion("0.0") + CRYPTOGRAPHY_VERSION = LooseVersion("0.0") # pylint: disable=invalid-name +else: + # pylint: disable-next=invalid-name + CRYPTOGRAPHY_VERSION = LooseVersion(cryptography.__version__) from ansible.module_utils.basic import AnsibleModule diff --git a/plugins/modules/openssl_signature_info.py b/plugins/modules/openssl_signature_info.py index 3095eff7..e3d6ee3f 100644 --- a/plugins/modules/openssl_signature_info.py +++ b/plugins/modules/openssl_signature_info.py @@ -106,9 +106,11 @@ try: import cryptography.hazmat.primitives.asymmetric.padding import cryptography.hazmat.primitives.hashes - CRYPTOGRAPHY_VERSION = LooseVersion(cryptography.__version__) except ImportError: - CRYPTOGRAPHY_VERSION = LooseVersion("0.0") + CRYPTOGRAPHY_VERSION = LooseVersion("0.0") # pylint: disable=invalid-name +else: + # pylint: disable-next=invalid-name + CRYPTOGRAPHY_VERSION = LooseVersion(cryptography.__version__) from ansible.module_utils.basic import AnsibleModule