diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2022-12-20 21:44:47 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-21 09:44:47 +0700 |
| commit | 7ff729ecf2ffeffc8442811a7ad5c8a9ab24351c (patch) | |
| tree | d76a1971dcfa7ccf567bae9032799c475a955207 /src | |
| parent | 4868142f4193c441b4995f54c70caad7b06dc093 (diff) | |
| download | cryptography-7ff729ecf2ffeffc8442811a7ad5c8a9ab24351c.tar.gz | |
Switch from flake8 to ruff (#7920)
It's more than 60x faster.
Diffstat (limited to 'src')
48 files changed, 48 insertions, 114 deletions
diff --git a/src/_cffi_src/utils.py b/src/_cffi_src/utils.py index 5afc084a3..47d31b611 100644 --- a/src/_cffi_src/utils.py +++ b/src/_cffi_src/utils.py @@ -10,7 +10,6 @@ from distutils.dist import Distribution from cffi import FFI - # Load the cryptography __about__ to get the current package version base_src = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) about = {} diff --git a/src/cryptography/__init__.py b/src/cryptography/__init__.py index 6c0fd2a62..07c894ea3 100644 --- a/src/cryptography/__init__.py +++ b/src/cryptography/__init__.py @@ -5,14 +5,9 @@ import sys import warnings -from cryptography.__about__ import ( - __author__, - __copyright__, - __version__, -) +from cryptography.__about__ import __author__, __copyright__, __version__ from cryptography.utils import CryptographyDeprecationWarning - __all__ = [ "__version__", "__author__", diff --git a/src/cryptography/hazmat/backends/openssl/__init__.py b/src/cryptography/hazmat/backends/openssl/__init__.py index 31fd17c3b..42c4539df 100644 --- a/src/cryptography/hazmat/backends/openssl/__init__.py +++ b/src/cryptography/hazmat/backends/openssl/__init__.py @@ -5,5 +5,4 @@ from cryptography.hazmat.backends.openssl.backend import backend - __all__ = ["backend"] diff --git a/src/cryptography/hazmat/backends/openssl/aead.py b/src/cryptography/hazmat/backends/openssl/aead.py index aa106fc3a..5b0fd2217 100644 --- a/src/cryptography/hazmat/backends/openssl/aead.py +++ b/src/cryptography/hazmat/backends/openssl/aead.py @@ -6,7 +6,6 @@ import typing from cryptography.exceptions import InvalidTag - if typing.TYPE_CHECKING: from cryptography.hazmat.backends.openssl.backend import Backend from cryptography.hazmat.primitives.ciphers.aead import ( diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index caa545824..5294e5d14 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -16,10 +16,10 @@ from cryptography.hazmat.backends.openssl import aead from cryptography.hazmat.backends.openssl.ciphers import _CipherContext from cryptography.hazmat.backends.openssl.cmac import _CMACContext from cryptography.hazmat.backends.openssl.dh import ( + _dh_params_dup, _DHParameters, _DHPrivateKey, _DHPublicKey, - _dh_params_dup, ) from cryptography.hazmat.backends.openssl.dsa import ( _DSAParameters, @@ -57,9 +57,7 @@ from cryptography.hazmat.backends.openssl.x448 import ( _X448PrivateKey, _X448PublicKey, ) -from cryptography.hazmat.bindings._rust import ( - x509 as rust_x509, -) +from cryptography.hazmat.bindings._rust import x509 as rust_x509 from cryptography.hazmat.bindings.openssl import binding from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives._asymmetric import AsymmetricPadding @@ -76,8 +74,8 @@ from cryptography.hazmat.primitives.asymmetric import ( from cryptography.hazmat.primitives.asymmetric.padding import ( MGF1, OAEP, - PKCS1v15, PSS, + PKCS1v15, ) from cryptography.hazmat.primitives.asymmetric.types import ( CERTIFICATE_ISSUER_PUBLIC_KEY_TYPES, @@ -93,9 +91,9 @@ from cryptography.hazmat.primitives.ciphers.algorithms import ( AES128, AES256, ARC4, + SM4, Camellia, ChaCha20, - SM4, TripleDES, _BlowfishInternal, _CAST5Internal, @@ -109,21 +107,20 @@ from cryptography.hazmat.primitives.ciphers.modes import ( CTR, ECB, GCM, - Mode, OFB, XTS, + Mode, ) from cryptography.hazmat.primitives.kdf import scrypt from cryptography.hazmat.primitives.serialization import ssh from cryptography.hazmat.primitives.serialization.pkcs12 import ( + _ALLOWED_PKCS12_TYPES, + _PKCS12_CAS_TYPES, PBES, PKCS12Certificate, PKCS12KeyAndCertificates, - _ALLOWED_PKCS12_TYPES, - _PKCS12_CAS_TYPES, ) - _MemoryBIO = collections.namedtuple("_MemoryBIO", ["bio", "char_ptr"]) diff --git a/src/cryptography/hazmat/backends/openssl/ciphers.py b/src/cryptography/hazmat/backends/openssl/ciphers.py index 1058de9f1..fd2b6612f 100644 --- a/src/cryptography/hazmat/backends/openssl/ciphers.py +++ b/src/cryptography/hazmat/backends/openssl/ciphers.py @@ -8,7 +8,6 @@ from cryptography.exceptions import InvalidTag, UnsupportedAlgorithm, _Reasons from cryptography.hazmat.primitives import ciphers from cryptography.hazmat.primitives.ciphers import algorithms, modes - if typing.TYPE_CHECKING: from cryptography.hazmat.backends.openssl.backend import Backend diff --git a/src/cryptography/hazmat/backends/openssl/cmac.py b/src/cryptography/hazmat/backends/openssl/cmac.py index 35f50c5c4..6f7363294 100644 --- a/src/cryptography/hazmat/backends/openssl/cmac.py +++ b/src/cryptography/hazmat/backends/openssl/cmac.py @@ -13,8 +13,8 @@ from cryptography.hazmat.primitives import constant_time from cryptography.hazmat.primitives.ciphers.modes import CBC if typing.TYPE_CHECKING: - from cryptography.hazmat.primitives import ciphers from cryptography.hazmat.backends.openssl.backend import Backend + from cryptography.hazmat.primitives import ciphers class _CMACContext: diff --git a/src/cryptography/hazmat/backends/openssl/dh.py b/src/cryptography/hazmat/backends/openssl/dh.py index 33fed6a40..c429c0239 100644 --- a/src/cryptography/hazmat/backends/openssl/dh.py +++ b/src/cryptography/hazmat/backends/openssl/dh.py @@ -8,7 +8,6 @@ from cryptography.exceptions import UnsupportedAlgorithm, _Reasons from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric import dh - if typing.TYPE_CHECKING: from cryptography.hazmat.backends.openssl.backend import Backend diff --git a/src/cryptography/hazmat/backends/openssl/dsa.py b/src/cryptography/hazmat/backends/openssl/dsa.py index 8634b7256..15bd84a7b 100644 --- a/src/cryptography/hazmat/backends/openssl/dsa.py +++ b/src/cryptography/hazmat/backends/openssl/dsa.py @@ -10,11 +10,8 @@ from cryptography.hazmat.backends.openssl.utils import ( _calculate_digest_and_algorithm, ) from cryptography.hazmat.primitives import hashes, serialization -from cryptography.hazmat.primitives.asymmetric import ( - dsa, - utils as asym_utils, -) - +from cryptography.hazmat.primitives.asymmetric import dsa +from cryptography.hazmat.primitives.asymmetric import utils as asym_utils if typing.TYPE_CHECKING: from cryptography.hazmat.backends.openssl.backend import Backend diff --git a/src/cryptography/hazmat/backends/openssl/ed25519.py b/src/cryptography/hazmat/backends/openssl/ed25519.py index 0ed69245a..6f393e5b6 100644 --- a/src/cryptography/hazmat/backends/openssl/ed25519.py +++ b/src/cryptography/hazmat/backends/openssl/ed25519.py @@ -7,10 +7,10 @@ import typing from cryptography import exceptions from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.asymmetric.ed25519 import ( - Ed25519PrivateKey, - Ed25519PublicKey, _ED25519_KEY_SIZE, _ED25519_SIG_SIZE, + Ed25519PrivateKey, + Ed25519PublicKey, ) if typing.TYPE_CHECKING: diff --git a/src/cryptography/hazmat/backends/openssl/hashes.py b/src/cryptography/hazmat/backends/openssl/hashes.py index 278b3815d..52d4646a7 100644 --- a/src/cryptography/hazmat/backends/openssl/hashes.py +++ b/src/cryptography/hazmat/backends/openssl/hashes.py @@ -7,7 +7,6 @@ import typing from cryptography.exceptions import UnsupportedAlgorithm, _Reasons from cryptography.hazmat.primitives import hashes - if typing.TYPE_CHECKING: from cryptography.hazmat.backends.openssl.backend import Backend diff --git a/src/cryptography/hazmat/backends/openssl/hmac.py b/src/cryptography/hazmat/backends/openssl/hmac.py index 5fd540747..ba3dfb53f 100644 --- a/src/cryptography/hazmat/backends/openssl/hmac.py +++ b/src/cryptography/hazmat/backends/openssl/hmac.py @@ -11,7 +11,6 @@ from cryptography.exceptions import ( ) from cryptography.hazmat.primitives import constant_time, hashes - if typing.TYPE_CHECKING: from cryptography.hazmat.backends.openssl.backend import Backend diff --git a/src/cryptography/hazmat/backends/openssl/poly1305.py b/src/cryptography/hazmat/backends/openssl/poly1305.py index dd6d376f0..d0d44f6fd 100644 --- a/src/cryptography/hazmat/backends/openssl/poly1305.py +++ b/src/cryptography/hazmat/backends/openssl/poly1305.py @@ -7,7 +7,6 @@ import typing from cryptography.exceptions import InvalidSignature from cryptography.hazmat.primitives import constant_time - _POLY1305_TAG_SIZE = 16 _POLY1305_KEY_SIZE = 32 diff --git a/src/cryptography/hazmat/backends/openssl/rsa.py b/src/cryptography/hazmat/backends/openssl/rsa.py index 694829d2c..e18bab3ff 100644 --- a/src/cryptography/hazmat/backends/openssl/rsa.py +++ b/src/cryptography/hazmat/backends/openssl/rsa.py @@ -14,15 +14,13 @@ from cryptography.hazmat.backends.openssl.utils import ( _calculate_digest_and_algorithm, ) from cryptography.hazmat.primitives import hashes, serialization -from cryptography.hazmat.primitives.asymmetric import ( - utils as asym_utils, -) +from cryptography.hazmat.primitives.asymmetric import utils as asym_utils from cryptography.hazmat.primitives.asymmetric.padding import ( - AsymmetricPadding, MGF1, OAEP, - PKCS1v15, PSS, + AsymmetricPadding, + PKCS1v15, _Auto, _DigestLength, _MaxLength, @@ -35,7 +33,6 @@ from cryptography.hazmat.primitives.asymmetric.rsa import ( RSAPublicNumbers, ) - if typing.TYPE_CHECKING: from cryptography.hazmat.backends.openssl.backend import Backend diff --git a/src/cryptography/hazmat/bindings/_rust/__init__.pyi b/src/cryptography/hazmat/bindings/_rust/__init__.pyi index 94a37a20a..d7642fcc4 100644 --- a/src/cryptography/hazmat/bindings/_rust/__init__.pyi +++ b/src/cryptography/hazmat/bindings/_rust/__init__.pyi @@ -22,7 +22,7 @@ class FixedPool(typing.Generic[T]): self, create: typing.Callable[[], T], ) -> None: ... - def acquire(self) -> PoolAcquisition[T]: ... + def acquire(self) -> "PoolAcquisition[T]": ... class PoolAcquisition(typing.Generic[T]): def __enter__(self) -> T: ... diff --git a/src/cryptography/hazmat/bindings/_rust/ocsp.pyi b/src/cryptography/hazmat/bindings/_rust/ocsp.pyi index acdea3dd2..47a037ade 100644 --- a/src/cryptography/hazmat/bindings/_rust/ocsp.pyi +++ b/src/cryptography/hazmat/bindings/_rust/ocsp.pyi @@ -4,15 +4,14 @@ import typing -from cryptography.hazmat.primitives.asymmetric.types import PRIVATE_KEY_TYPES from cryptography.hazmat.primitives import hashes -from cryptography.x509 import Extension +from cryptography.hazmat.primitives.asymmetric.types import PRIVATE_KEY_TYPES from cryptography.x509.ocsp import ( OCSPRequest, OCSPRequestBuilder, OCSPResponse, - OCSPResponseStatus, OCSPResponseBuilder, + OCSPResponseStatus, ) def load_der_ocsp_request(data: bytes) -> OCSPRequest: ... diff --git a/src/cryptography/hazmat/bindings/_rust/pkcs7.pyi b/src/cryptography/hazmat/bindings/_rust/pkcs7.pyi index 6cbc0bcf7..66bd85098 100644 --- a/src/cryptography/hazmat/bindings/_rust/pkcs7.pyi +++ b/src/cryptography/hazmat/bindings/_rust/pkcs7.pyi @@ -1,8 +1,8 @@ import typing +from cryptography import x509 from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives.serialization import pkcs7 -from cryptography import x509 def serialize_certificates( certs: typing.List[x509.Certificate], diff --git a/src/cryptography/hazmat/bindings/_rust/x509.pyi b/src/cryptography/hazmat/bindings/_rust/x509.pyi index d92ea6c6a..1bbde8005 100644 --- a/src/cryptography/hazmat/bindings/_rust/x509.pyi +++ b/src/cryptography/hazmat/bindings/_rust/x509.pyi @@ -2,7 +2,6 @@ # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. -import datetime import typing from cryptography import x509 diff --git a/src/cryptography/hazmat/primitives/_asymmetric.py b/src/cryptography/hazmat/primitives/_asymmetric.py index cdadbdeff..c6862d931 100644 --- a/src/cryptography/hazmat/primitives/_asymmetric.py +++ b/src/cryptography/hazmat/primitives/_asymmetric.py @@ -4,7 +4,6 @@ import abc - # This exists to break an import cycle. It is normally accessible from the # asymmetric padding module. diff --git a/src/cryptography/hazmat/primitives/_cipheralgorithm.py b/src/cryptography/hazmat/primitives/_cipheralgorithm.py index 7f322048d..6e6a79c11 100644 --- a/src/cryptography/hazmat/primitives/_cipheralgorithm.py +++ b/src/cryptography/hazmat/primitives/_cipheralgorithm.py @@ -5,7 +5,6 @@ import abc import typing - # This exists to break an import cycle. It is normally accessible from the # ciphers module. diff --git a/src/cryptography/hazmat/primitives/asymmetric/dh.py b/src/cryptography/hazmat/primitives/asymmetric/dh.py index 2093ad4a6..bbdd485cd 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/dh.py +++ b/src/cryptography/hazmat/primitives/asymmetric/dh.py @@ -8,7 +8,6 @@ import typing from cryptography.hazmat.primitives import _serialization - _MIN_MODULUS_SIZE = 512 diff --git a/src/cryptography/hazmat/primitives/asymmetric/dsa.py b/src/cryptography/hazmat/primitives/asymmetric/dsa.py index 5e587097c..e013d6204 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/dsa.py +++ b/src/cryptography/hazmat/primitives/asymmetric/dsa.py @@ -7,9 +7,7 @@ import abc import typing from cryptography.hazmat.primitives import _serialization, hashes -from cryptography.hazmat.primitives.asymmetric import ( - utils as asym_utils, -) +from cryptography.hazmat.primitives.asymmetric import utils as asym_utils class DSAParameters(metaclass=abc.ABCMeta): diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py index 4d949da5e..062b33c34 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/ec.py +++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py @@ -9,9 +9,7 @@ import typing from cryptography import utils from cryptography.hazmat._oid import ObjectIdentifier from cryptography.hazmat.primitives import _serialization, hashes -from cryptography.hazmat.primitives.asymmetric import ( - utils as asym_utils, -) +from cryptography.hazmat.primitives.asymmetric import utils as asym_utils class EllipticCurveOID: diff --git a/src/cryptography/hazmat/primitives/asymmetric/ed25519.py b/src/cryptography/hazmat/primitives/asymmetric/ed25519.py index 432770283..220bf592c 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/ed25519.py +++ b/src/cryptography/hazmat/primitives/asymmetric/ed25519.py @@ -8,7 +8,6 @@ import abc from cryptography.exceptions import UnsupportedAlgorithm, _Reasons from cryptography.hazmat.primitives import _serialization - _ED25519_KEY_SIZE = 32 _ED25519_SIG_SIZE = 64 diff --git a/src/cryptography/hazmat/primitives/asymmetric/rsa.py b/src/cryptography/hazmat/primitives/asymmetric/rsa.py index 36d360f22..433f925de 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/rsa.py +++ b/src/cryptography/hazmat/primitives/asymmetric/rsa.py @@ -9,9 +9,7 @@ from math import gcd from cryptography.hazmat.primitives import _serialization, hashes from cryptography.hazmat.primitives._asymmetric import AsymmetricPadding -from cryptography.hazmat.primitives.asymmetric import ( - utils as asym_utils, -) +from cryptography.hazmat.primitives.asymmetric import utils as asym_utils class RSAPrivateKey(metaclass=abc.ABCMeta): diff --git a/src/cryptography/hazmat/primitives/asymmetric/types.py b/src/cryptography/hazmat/primitives/asymmetric/types.py index d49781524..369fbf8f2 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/types.py +++ b/src/cryptography/hazmat/primitives/asymmetric/types.py @@ -15,7 +15,6 @@ from cryptography.hazmat.primitives.asymmetric import ( x448, ) - # Every asymmetric key type PUBLIC_KEY_TYPES = typing.Union[ dh.DHPublicKey, diff --git a/src/cryptography/hazmat/primitives/asymmetric/utils.py b/src/cryptography/hazmat/primitives/asymmetric/utils.py index 638ecb351..140ca1960 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/utils.py +++ b/src/cryptography/hazmat/primitives/asymmetric/utils.py @@ -6,7 +6,6 @@ from cryptography.hazmat.bindings._rust import asn1 from cryptography.hazmat.primitives import hashes - decode_dss_signature = asn1.decode_dss_signature encode_dss_signature = asn1.encode_dss_signature diff --git a/src/cryptography/hazmat/primitives/ciphers/__init__.py b/src/cryptography/hazmat/primitives/ciphers/__init__.py index 874dbd456..95f02842a 100644 --- a/src/cryptography/hazmat/primitives/ciphers/__init__.py +++ b/src/cryptography/hazmat/primitives/ciphers/__init__.py @@ -15,7 +15,6 @@ from cryptography.hazmat.primitives.ciphers.base import ( CipherContext, ) - __all__ = [ "Cipher", "CipherAlgorithm", diff --git a/src/cryptography/hazmat/primitives/ciphers/base.py b/src/cryptography/hazmat/primitives/ciphers/base.py index 7af305249..886afa173 100644 --- a/src/cryptography/hazmat/primitives/ciphers/base.py +++ b/src/cryptography/hazmat/primitives/ciphers/base.py @@ -14,7 +14,6 @@ from cryptography.exceptions import ( from cryptography.hazmat.primitives._cipheralgorithm import CipherAlgorithm from cryptography.hazmat.primitives.ciphers import modes - if typing.TYPE_CHECKING: from cryptography.hazmat.backends.openssl.ciphers import ( _CipherContext as _BackendCipherContext, diff --git a/src/cryptography/hazmat/primitives/cmac.py b/src/cryptography/hazmat/primitives/cmac.py index 1ec756a8e..00c4bd11d 100644 --- a/src/cryptography/hazmat/primitives/cmac.py +++ b/src/cryptography/hazmat/primitives/cmac.py @@ -6,9 +6,7 @@ import typing from cryptography import utils -from cryptography.exceptions import ( - AlreadyFinalized, -) +from cryptography.exceptions import AlreadyFinalized from cryptography.hazmat.primitives import ciphers if typing.TYPE_CHECKING: diff --git a/src/cryptography/hazmat/primitives/hashes.py b/src/cryptography/hazmat/primitives/hashes.py index ba22a6646..440b1a3e9 100644 --- a/src/cryptography/hazmat/primitives/hashes.py +++ b/src/cryptography/hazmat/primitives/hashes.py @@ -6,9 +6,7 @@ import abc import typing from cryptography import utils -from cryptography.exceptions import ( - AlreadyFinalized, -) +from cryptography.exceptions import AlreadyFinalized class HashAlgorithm(metaclass=abc.ABCMeta): diff --git a/src/cryptography/hazmat/primitives/hmac.py b/src/cryptography/hazmat/primitives/hmac.py index 1577326c9..8f1c0eae6 100644 --- a/src/cryptography/hazmat/primitives/hmac.py +++ b/src/cryptography/hazmat/primitives/hmac.py @@ -6,9 +6,7 @@ import typing from cryptography import utils -from cryptography.exceptions import ( - AlreadyFinalized, -) +from cryptography.exceptions import AlreadyFinalized from cryptography.hazmat.backends.openssl.hmac import _HMACContext from cryptography.hazmat.primitives import hashes diff --git a/src/cryptography/hazmat/primitives/kdf/concatkdf.py b/src/cryptography/hazmat/primitives/kdf/concatkdf.py index 0b0262ebb..94312fec3 100644 --- a/src/cryptography/hazmat/primitives/kdf/concatkdf.py +++ b/src/cryptography/hazmat/primitives/kdf/concatkdf.py @@ -6,10 +6,7 @@ import typing from cryptography import utils -from cryptography.exceptions import ( - AlreadyFinalized, - InvalidKey, -) +from cryptography.exceptions import AlreadyFinalized, InvalidKey from cryptography.hazmat.primitives import constant_time, hashes, hmac from cryptography.hazmat.primitives.kdf import KeyDerivationFunction diff --git a/src/cryptography/hazmat/primitives/kdf/hkdf.py b/src/cryptography/hazmat/primitives/kdf/hkdf.py index 44889b67b..2152ae220 100644 --- a/src/cryptography/hazmat/primitives/kdf/hkdf.py +++ b/src/cryptography/hazmat/primitives/kdf/hkdf.py @@ -6,10 +6,7 @@ import typing from cryptography import utils -from cryptography.exceptions import ( - AlreadyFinalized, - InvalidKey, -) +from cryptography.exceptions import AlreadyFinalized, InvalidKey from cryptography.hazmat.primitives import constant_time, hashes, hmac from cryptography.hazmat.primitives.kdf import KeyDerivationFunction diff --git a/src/cryptography/hazmat/primitives/kdf/scrypt.py b/src/cryptography/hazmat/primitives/kdf/scrypt.py index ff81bbb1f..286f4388c 100644 --- a/src/cryptography/hazmat/primitives/kdf/scrypt.py +++ b/src/cryptography/hazmat/primitives/kdf/scrypt.py @@ -15,7 +15,6 @@ from cryptography.exceptions import ( from cryptography.hazmat.primitives import constant_time from cryptography.hazmat.primitives.kdf import KeyDerivationFunction - # This is used by the scrypt tests to skip tests that require more memory # than the MEM_LIMIT _MEM_LIMIT = sys.maxsize // 2 diff --git a/src/cryptography/hazmat/primitives/kdf/x963kdf.py b/src/cryptography/hazmat/primitives/kdf/x963kdf.py index aa6bcc1d1..651e691aa 100644 --- a/src/cryptography/hazmat/primitives/kdf/x963kdf.py +++ b/src/cryptography/hazmat/primitives/kdf/x963kdf.py @@ -6,10 +6,7 @@ import typing from cryptography import utils -from cryptography.exceptions import ( - AlreadyFinalized, - InvalidKey, -) +from cryptography.exceptions import AlreadyFinalized, InvalidKey from cryptography.hazmat.primitives import constant_time, hashes from cryptography.hazmat.primitives.kdf import KeyDerivationFunction diff --git a/src/cryptography/hazmat/primitives/serialization/__init__.py b/src/cryptography/hazmat/primitives/serialization/__init__.py index 60241500c..af4112f39 100644 --- a/src/cryptography/hazmat/primitives/serialization/__init__.py +++ b/src/cryptography/hazmat/primitives/serialization/__init__.py @@ -26,7 +26,6 @@ from cryptography.hazmat.primitives.serialization.ssh import ( load_ssh_public_key, ) - __all__ = [ "load_der_parameters", "load_der_private_key", diff --git a/src/cryptography/hazmat/primitives/serialization/pkcs12.py b/src/cryptography/hazmat/primitives/serialization/pkcs12.py index 662ea75af..b4d9a3436 100644 --- a/src/cryptography/hazmat/primitives/serialization/pkcs12.py +++ b/src/cryptography/hazmat/primitives/serialization/pkcs12.py @@ -14,9 +14,7 @@ from cryptography.hazmat.primitives.asymmetric import ( ed448, rsa, ) -from cryptography.hazmat.primitives.asymmetric.types import ( - PRIVATE_KEY_TYPES, -) +from cryptography.hazmat.primitives.asymmetric.types import PRIVATE_KEY_TYPES __all__ = [ "PBES", diff --git a/src/cryptography/hazmat/primitives/serialization/pkcs7.py b/src/cryptography/hazmat/primitives/serialization/pkcs7.py index 5eaeab388..7e593e719 100644 --- a/src/cryptography/hazmat/primitives/serialization/pkcs7.py +++ b/src/cryptography/hazmat/primitives/serialization/pkcs7.py @@ -8,8 +8,7 @@ import email.message import io import typing -from cryptography import utils -from cryptography import x509 +from cryptography import utils, x509 from cryptography.hazmat.bindings._rust import pkcs7 as rust_pkcs7 from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric import ec, rsa diff --git a/src/cryptography/hazmat/primitives/twofactor/hotp.py b/src/cryptography/hazmat/primitives/twofactor/hotp.py index 9730af2b7..04c45bb8c 100644 --- a/src/cryptography/hazmat/primitives/twofactor/hotp.py +++ b/src/cryptography/hazmat/primitives/twofactor/hotp.py @@ -11,7 +11,6 @@ from cryptography.hazmat.primitives import constant_time, hmac from cryptography.hazmat.primitives.hashes import SHA1, SHA256, SHA512 from cryptography.hazmat.primitives.twofactor import InvalidToken - _ALLOWED_HASH_TYPES = typing.Union[SHA1, SHA256, SHA512] diff --git a/src/cryptography/hazmat/primitives/twofactor/totp.py b/src/cryptography/hazmat/primitives/twofactor/totp.py index 317baba35..314dbef71 100644 --- a/src/cryptography/hazmat/primitives/twofactor/totp.py +++ b/src/cryptography/hazmat/primitives/twofactor/totp.py @@ -7,8 +7,8 @@ import typing from cryptography.hazmat.primitives import constant_time from cryptography.hazmat.primitives.twofactor import InvalidToken from cryptography.hazmat.primitives.twofactor.hotp import ( - HOTP, _ALLOWED_HASH_TYPES, + HOTP, _generate_uri, ) diff --git a/src/cryptography/x509/__init__.py b/src/cryptography/x509/__init__.py index b3f6e608f..ad924ad42 100644 --- a/src/cryptography/x509/__init__.py +++ b/src/cryptography/x509/__init__.py @@ -32,19 +32,19 @@ from cryptography.x509.extensions import ( AuthorityInformationAccess, AuthorityKeyIdentifier, BasicConstraints, + CertificateIssuer, + CertificatePolicies, CRLDistributionPoints, CRLNumber, CRLReason, - CertificateIssuer, - CertificatePolicies, DeltaCRLIndicator, DistributionPoint, DuplicateExtension, ExtendedKeyUsage, Extension, ExtensionNotFound, - ExtensionType, Extensions, + ExtensionType, FreshestCRL, GeneralNames, InhibitAnyPolicy, @@ -58,8 +58,8 @@ from cryptography.x509.extensions import ( OCSPNonce, PolicyConstraints, PolicyInformation, - PrecertPoison, PrecertificateSignedCertificateTimestamps, + PrecertPoison, ReasonFlags, SignedCertificateTimestamps, SubjectAlternativeName, @@ -71,13 +71,13 @@ from cryptography.x509.extensions import ( UserNotice, ) from cryptography.x509.general_name import ( - DNSName, DirectoryName, + DNSName, GeneralName, IPAddress, OtherName, - RFC822Name, RegisteredID, + RFC822Name, UniformResourceIdentifier, UnsupportedGeneralNameType, ) @@ -88,8 +88,8 @@ from cryptography.x509.name import ( ) from cryptography.x509.oid import ( AuthorityInformationAccessOID, - CRLEntryExtensionOID, CertificatePoliciesOID, + CRLEntryExtensionOID, ExtendedKeyUsageOID, ExtensionOID, NameOID, @@ -97,7 +97,6 @@ from cryptography.x509.oid import ( SignatureAlgorithmOID, ) - OID_AUTHORITY_INFORMATION_ACCESS = ExtensionOID.AUTHORITY_INFORMATION_ACCESS OID_AUTHORITY_KEY_IDENTIFIER = ExtensionOID.AUTHORITY_KEY_IDENTIFIER OID_BASIC_CONSTRAINTS = ExtensionOID.BASIC_CONSTRAINTS diff --git a/src/cryptography/x509/base.py b/src/cryptography/x509/base.py index 9c0aad530..49713f4c9 100644 --- a/src/cryptography/x509/base.py +++ b/src/cryptography/x509/base.py @@ -27,14 +27,13 @@ from cryptography.hazmat.primitives.asymmetric.types import ( ) from cryptography.x509.extensions import ( Extension, - ExtensionType, Extensions, + ExtensionType, _make_sequence_methods, ) from cryptography.x509.name import Name, _ASN1Type from cryptography.x509.oid import ObjectIdentifier - _EARLIEST_UTC_TIME = datetime.datetime(1950, 1, 1) diff --git a/src/cryptography/x509/extensions.py b/src/cryptography/x509/extensions.py index 36be6f253..2012515f2 100644 --- a/src/cryptography/x509/extensions.py +++ b/src/cryptography/x509/extensions.py @@ -23,22 +23,22 @@ from cryptography.x509.certificate_transparency import ( SignedCertificateTimestamp, ) from cryptography.x509.general_name import ( - DNSName, + _IPADDRESS_TYPES, DirectoryName, + DNSName, GeneralName, IPAddress, OtherName, - RFC822Name, RegisteredID, + RFC822Name, UniformResourceIdentifier, - _IPADDRESS_TYPES, ) from cryptography.x509.name import Name, RelativeDistinguishedName from cryptography.x509.oid import ( CRLEntryExtensionOID, ExtensionOID, - OCSPExtensionOID, ObjectIdentifier, + OCSPExtensionOID, ) ExtensionTypeVar = typing.TypeVar( diff --git a/src/cryptography/x509/general_name.py b/src/cryptography/x509/general_name.py index 9939233fe..a2f12b34b 100644 --- a/src/cryptography/x509/general_name.py +++ b/src/cryptography/x509/general_name.py @@ -11,7 +11,6 @@ from email.utils import parseaddr from cryptography.x509.name import Name from cryptography.x509.oid import ObjectIdentifier - _IPADDRESS_TYPES = typing.Union[ ipaddress.IPv4Address, ipaddress.IPv6Address, diff --git a/src/cryptography/x509/name.py b/src/cryptography/x509/name.py index 702fb4b21..acd7c0f1e 100644 --- a/src/cryptography/x509/name.py +++ b/src/cryptography/x509/name.py @@ -9,9 +9,7 @@ import typing import warnings from cryptography import utils -from cryptography.hazmat.bindings._rust import ( - x509 as rust_x509, -) +from cryptography.hazmat.bindings._rust import x509 as rust_x509 from cryptography.x509.oid import NameOID, ObjectIdentifier diff --git a/src/cryptography/x509/ocsp.py b/src/cryptography/x509/ocsp.py index 0e59fa4bc..4a08525a7 100644 --- a/src/cryptography/x509/ocsp.py +++ b/src/cryptography/x509/ocsp.py @@ -7,8 +7,7 @@ import abc import datetime import typing -from cryptography import utils -from cryptography import x509 +from cryptography import utils, x509 from cryptography.hazmat.bindings._rust import ocsp from cryptography.hazmat.primitives import hashes, serialization from cryptography.hazmat.primitives.asymmetric.types import ( diff --git a/src/cryptography/x509/oid.py b/src/cryptography/x509/oid.py index 9bfac75a4..0d91a5469 100644 --- a/src/cryptography/x509/oid.py +++ b/src/cryptography/x509/oid.py @@ -5,18 +5,17 @@ from cryptography.hazmat._oid import ( AttributeOID, AuthorityInformationAccessOID, - CRLEntryExtensionOID, CertificatePoliciesOID, + CRLEntryExtensionOID, ExtendedKeyUsageOID, ExtensionOID, NameOID, - OCSPExtensionOID, ObjectIdentifier, + OCSPExtensionOID, SignatureAlgorithmOID, SubjectInformationAccessOID, ) - __all__ = [ "AttributeOID", "AuthorityInformationAccessOID", |
