mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-03-26 21:33:25 +00:00
Adjust to new pylint release.
This commit is contained in:
@@ -57,7 +57,7 @@ from ansible_collections.community.crypto.plugins.module_utils._version import (
|
|||||||
|
|
||||||
CRYPTOGRAPHY_MINIMAL_VERSION = "1.5"
|
CRYPTOGRAPHY_MINIMAL_VERSION = "1.5"
|
||||||
|
|
||||||
CRYPTOGRAPHY_ERROR = None
|
CRYPTOGRAPHY_ERROR: None | str
|
||||||
try:
|
try:
|
||||||
import cryptography
|
import cryptography
|
||||||
import cryptography.hazmat.backends
|
import cryptography.hazmat.backends
|
||||||
@@ -71,14 +71,15 @@ try:
|
|||||||
import cryptography.x509
|
import cryptography.x509
|
||||||
import cryptography.x509.oid
|
import cryptography.x509.oid
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_CURRENT_CRYPTOGRAPHY = False
|
HAS_CURRENT_CRYPTOGRAPHY = False # pylint: disable=invalid-name
|
||||||
CRYPTOGRAPHY_VERSION = None
|
CRYPTOGRAPHY_VERSION = None # pylint: disable=invalid-name
|
||||||
CRYPTOGRAPHY_ERROR = traceback.format_exc()
|
CRYPTOGRAPHY_ERROR = traceback.format_exc() # pylint: disable=invalid-name
|
||||||
else:
|
else:
|
||||||
CRYPTOGRAPHY_VERSION = cryptography.__version__
|
CRYPTOGRAPHY_VERSION = cryptography.__version__ # pylint: disable=invalid-name
|
||||||
HAS_CURRENT_CRYPTOGRAPHY = LooseVersion(CRYPTOGRAPHY_VERSION) >= LooseVersion(
|
HAS_CURRENT_CRYPTOGRAPHY = LooseVersion(CRYPTOGRAPHY_VERSION) >= LooseVersion(
|
||||||
CRYPTOGRAPHY_MINIMAL_VERSION
|
CRYPTOGRAPHY_MINIMAL_VERSION
|
||||||
)
|
)
|
||||||
|
CRYPTOGRAPHY_ERROR = None # pylint: disable=invalid-name
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
import datetime # pragma: no cover
|
import datetime # pragma: no cover
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ if t.TYPE_CHECKING:
|
|||||||
# TODO: once cryptography has a _utc variant of InvalidityDate.invalidity_date, set this
|
# TODO: once cryptography has a _utc variant of InvalidityDate.invalidity_date, set this
|
||||||
# to True and adjust get_invalidity_date() accordingly.
|
# to True and adjust get_invalidity_date() accordingly.
|
||||||
# (https://github.com/pyca/cryptography/issues/10818)
|
# (https://github.com/pyca/cryptography/issues/10818)
|
||||||
CRYPTOGRAPHY_TIMEZONE_INVALIDITY_DATE = False
|
CRYPTOGRAPHY_TIMEZONE_INVALIDITY_DATE = False # pylint: disable=invalid-name
|
||||||
if HAS_CRYPTOGRAPHY:
|
if HAS_CRYPTOGRAPHY:
|
||||||
CRYPTOGRAPHY_TIMEZONE_INVALIDITY_DATE = _LooseVersion(
|
CRYPTOGRAPHY_TIMEZONE_INVALIDITY_DATE = _LooseVersion(
|
||||||
cryptography.__version__
|
cryptography.__version__
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ else:
|
|||||||
PrivateKeyTypesWOEdwards = None # pylint: disable=invalid-name
|
PrivateKeyTypesWOEdwards = None # pylint: disable=invalid-name
|
||||||
|
|
||||||
|
|
||||||
CRYPTOGRAPHY_TIMEZONE = False
|
CRYPTOGRAPHY_TIMEZONE = False # pylint: disable=invalid-name
|
||||||
_CRYPTOGRAPHY_36_0_OR_NEWER = False
|
_CRYPTOGRAPHY_36_0_OR_NEWER = False # pylint: disable=invalid-name
|
||||||
if _HAS_CRYPTOGRAPHY:
|
if _HAS_CRYPTOGRAPHY:
|
||||||
CRYPTOGRAPHY_TIMEZONE = LooseVersion(cryptography.__version__) >= LooseVersion(
|
CRYPTOGRAPHY_TIMEZONE = LooseVersion(cryptography.__version__) >= LooseVersion(
|
||||||
"42.0.0"
|
"42.0.0"
|
||||||
|
|||||||
@@ -38,20 +38,21 @@ if t.TYPE_CHECKING:
|
|||||||
] # pragma: no cover
|
] # pragma: no cover
|
||||||
|
|
||||||
|
|
||||||
_CRYPTOGRAPHY_IMP_ERR: str | None = None
|
_CRYPTOGRAPHY_IMP_ERR: str | None = None # pylint: disable=invalid-name
|
||||||
_CRYPTOGRAPHY_FILE: str | None = None
|
_CRYPTOGRAPHY_FILE: str | None = None # pylint: disable=invalid-name
|
||||||
try:
|
try:
|
||||||
import cryptography
|
import cryptography
|
||||||
from cryptography import x509 # noqa: F401, pylint: disable=unused-import
|
from cryptography import x509 # noqa: F401, pylint: disable=unused-import
|
||||||
|
|
||||||
CRYPTOGRAPHY_VERSION = LooseVersion(cryptography.__version__)
|
|
||||||
_CRYPTOGRAPHY_FILE = cryptography.__file__
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_CRYPTOGRAPHY_IMP_ERR = traceback.format_exc()
|
_CRYPTOGRAPHY_IMP_ERR = traceback.format_exc() # pylint: disable=invalid-name
|
||||||
CRYPTOGRAPHY_FOUND = False
|
CRYPTOGRAPHY_FOUND = False
|
||||||
CRYPTOGRAPHY_VERSION = LooseVersion("0.0")
|
CRYPTOGRAPHY_VERSION = LooseVersion("0.0") # pylint: disable=invalid-name
|
||||||
else:
|
else:
|
||||||
CRYPTOGRAPHY_FOUND = True
|
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
|
# Corresponds to the community.crypto.cryptography_dep.minimum doc fragment
|
||||||
|
|||||||
@@ -174,12 +174,12 @@ except ImportError:
|
|||||||
UnsupportedAlgorithm = Exception # type: ignore
|
UnsupportedAlgorithm = Exception # type: ignore
|
||||||
CryptographyInternalError = Exception # type: ignore
|
CryptographyInternalError = Exception # type: ignore
|
||||||
HAS_CRYPTOGRAPHY = False
|
HAS_CRYPTOGRAPHY = False
|
||||||
CRYPTOGRAPHY_VERSION = None
|
CRYPTOGRAPHY_VERSION = None # pylint: disable=invalid-name
|
||||||
CRYPTOGRAPHY_IMP_ERR = traceback.format_exc()
|
CRYPTOGRAPHY_IMP_ERR = traceback.format_exc() # pylint: disable=invalid-name
|
||||||
else:
|
else:
|
||||||
HAS_CRYPTOGRAPHY = True
|
HAS_CRYPTOGRAPHY = True
|
||||||
CRYPTOGRAPHY_VERSION = cryptography.__version__
|
CRYPTOGRAPHY_VERSION = cryptography.__version__ # pylint: disable=invalid-name
|
||||||
CRYPTOGRAPHY_IMP_ERR = None
|
CRYPTOGRAPHY_IMP_ERR = None # pylint: disable=invalid-name
|
||||||
|
|
||||||
|
|
||||||
CURVES = (
|
CURVES = (
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
CRYPTOGRAPHY_COMPATIBILITY2022_ERR = None
|
CRYPTOGRAPHY_COMPATIBILITY2022_ERR: str | None
|
||||||
try:
|
try:
|
||||||
import cryptography.x509
|
import cryptography.x509
|
||||||
from cryptography.hazmat.primitives import hashes
|
from cryptography.hazmat.primitives import hashes
|
||||||
@@ -329,9 +329,11 @@ try:
|
|||||||
PBES.PBESv1SHA1And3KeyTripleDESCBC
|
PBES.PBESv1SHA1And3KeyTripleDESCBC
|
||||||
).hmac_hash(hashes.SHA1())
|
).hmac_hash(hashes.SHA1())
|
||||||
except Exception:
|
except Exception:
|
||||||
|
# pylint: disable-next=invalid-name
|
||||||
CRYPTOGRAPHY_COMPATIBILITY2022_ERR = traceback.format_exc()
|
CRYPTOGRAPHY_COMPATIBILITY2022_ERR = traceback.format_exc()
|
||||||
CRYPTOGRAPHY_HAS_COMPATIBILITY2022 = False
|
CRYPTOGRAPHY_HAS_COMPATIBILITY2022 = False
|
||||||
else:
|
else:
|
||||||
|
CRYPTOGRAPHY_COMPATIBILITY2022_ERR = None # pylint: disable=invalid-name
|
||||||
CRYPTOGRAPHY_HAS_COMPATIBILITY2022 = True
|
CRYPTOGRAPHY_HAS_COMPATIBILITY2022 = True
|
||||||
|
|
||||||
if t.TYPE_CHECKING:
|
if t.TYPE_CHECKING:
|
||||||
|
|||||||
@@ -117,9 +117,11 @@ try:
|
|||||||
import cryptography.hazmat.primitives.asymmetric.padding
|
import cryptography.hazmat.primitives.asymmetric.padding
|
||||||
import cryptography.hazmat.primitives.hashes
|
import cryptography.hazmat.primitives.hashes
|
||||||
|
|
||||||
CRYPTOGRAPHY_VERSION = LooseVersion(cryptography.__version__)
|
|
||||||
except ImportError:
|
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
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|||||||
@@ -106,9 +106,11 @@ try:
|
|||||||
import cryptography.hazmat.primitives.asymmetric.padding
|
import cryptography.hazmat.primitives.asymmetric.padding
|
||||||
import cryptography.hazmat.primitives.hashes
|
import cryptography.hazmat.primitives.hashes
|
||||||
|
|
||||||
CRYPTOGRAPHY_VERSION = LooseVersion(cryptography.__version__)
|
|
||||||
except ImportError:
|
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
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user