Skip to content

Commit fd3031a

Browse files
committed
reformat with ruff
1 parent cb9f5d2 commit fd3031a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+199
-334
lines changed

src/cryptojwt/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
from cryptojwt.key_jar import KeyJar
1212

1313
from .exception import BadSyntax
14-
from .utils import as_unicode
15-
from .utils import b64d
16-
from .utils import b64encode_item
17-
from .utils import split_token
14+
from .utils import as_unicode, b64d, b64encode_item, split_token
1815

1916
__version__ = version("cryptojwt")
2017

src/cryptojwt/jwe/aes.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
from struct import pack
33

44
from cryptography.hazmat.primitives import hmac
5-
from cryptography.hazmat.primitives.ciphers import Cipher
6-
from cryptography.hazmat.primitives.ciphers import algorithms
7-
from cryptography.hazmat.primitives.ciphers import modes
5+
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
86
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
97
from cryptography.hazmat.primitives.padding import PKCS7
108

11-
from ..exception import MissingKey
12-
from ..exception import Unsupported
13-
from ..exception import VerificationError
9+
from ..exception import MissingKey, Unsupported, VerificationError
1410
from . import Encrypter
1511
from .exception import UnsupportedBitLength
1612
from .utils import get_keys_seclen_dgst

src/cryptojwt/jwe/fernet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import base64
22
import os
3-
from typing import Optional
4-
from typing import Union
3+
from typing import Optional, Union
54

65
from cryptography.fernet import Fernet
76
from cryptography.hazmat.primitives import hashes

src/cryptojwt/jwe/jwe.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
from ..jwk.hmac import SYMKey
77
from ..jwk.jwk import key_from_jwk_dict
88
from ..jwx import JWx
9-
from .exception import DecryptionFailed
10-
from .exception import NoSuitableDecryptionKey
11-
from .exception import NoSuitableEncryptionKey
12-
from .exception import NotSupportedAlgorithm
13-
from .exception import WrongEncryptionAlgorithm
9+
from .exception import (
10+
DecryptionFailed,
11+
NoSuitableDecryptionKey,
12+
NoSuitableEncryptionKey,
13+
NotSupportedAlgorithm,
14+
WrongEncryptionAlgorithm,
15+
)
1416
from .jwe_ec import JWE_EC
1517
from .jwe_hmac import JWE_SYM
1618
from .jwe_rsa import JWE_RSA

src/cryptojwt/jwe/jwe_ec.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22
import struct
33

44
from cryptography.hazmat.primitives.asymmetric import ec
5-
from cryptography.hazmat.primitives.keywrap import aes_key_unwrap
6-
from cryptography.hazmat.primitives.keywrap import aes_key_wrap
7-
8-
from ..jwk.ec import NIST2SEC
9-
from ..jwk.ec import ECKey
10-
from ..utils import as_bytes
11-
from ..utils import as_unicode
12-
from ..utils import b64d
13-
from ..utils import b64e
5+
from cryptography.hazmat.primitives.keywrap import aes_key_unwrap, aes_key_wrap
6+
7+
from ..jwk.ec import NIST2SEC, ECKey
8+
from ..utils import as_bytes, as_unicode, b64d, b64e
149
from . import KEY_LEN
1510
from .jwekey import JWEKey
1611
from .jwenc import JWEnc
17-
from .utils import concat_sha256
18-
from .utils import get_random_bytes
12+
from .utils import concat_sha256, get_random_bytes
1913

2014

2115
def ecdh_derive_key(key, epk, apu, apv, alg, dk_len):

src/cryptojwt/jwe/jwe_hmac.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
import logging
33
import zlib
44

5-
from cryptography.hazmat.primitives.keywrap import aes_key_unwrap
6-
from cryptography.hazmat.primitives.keywrap import aes_key_wrap
5+
from cryptography.hazmat.primitives.keywrap import aes_key_unwrap, aes_key_wrap
76

8-
from ..exception import MissingKey
9-
from ..exception import WrongNumberOfParts
7+
from ..exception import MissingKey, WrongNumberOfParts
108
from ..jwk.hmac import SYMKey
11-
from ..utils import as_bytes
12-
from ..utils import intarr2str
9+
from ..utils import as_bytes, intarr2str
1310
from .jwekey import JWEKey
1411
from .jwenc import JWEnc
1512

src/cryptojwt/jwe/jwe_rsa.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
from ..utils import as_bytes
55
from . import SUPPORTED
6-
from .exception import NotSupportedAlgorithm
7-
from .exception import ParameterError
6+
from .exception import NotSupportedAlgorithm, ParameterError
87
from .jwekey import JWEKey
98
from .jwenc import JWEnc
109
from .rsa import RSAEncrypter

src/cryptojwt/jwe/jwekey.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
from ..jwx import JWx
22
from . import KEY_LEN_BYTES
3-
from .aes import AES_CBCEncrypter
4-
from .aes import AES_GCMEncrypter
5-
from .exception import DecryptionFailed
6-
from .exception import NotSupportedAlgorithm
7-
from .utils import alg2keytype
8-
from .utils import get_random_bytes
9-
from .utils import split_ctx_and_tag
3+
from .aes import AES_CBCEncrypter, AES_GCMEncrypter
4+
from .exception import DecryptionFailed, NotSupportedAlgorithm
5+
from .utils import alg2keytype, get_random_bytes, split_ctx_and_tag
106

117

128
class JWEKey(JWx):

src/cryptojwt/jwe/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
from math import ceil
44

55
from cryptography.hazmat.primitives import hashes
6-
from cryptography.hazmat.primitives.hashes import SHA256
7-
from cryptography.hazmat.primitives.hashes import SHA384
8-
from cryptography.hazmat.primitives.hashes import SHA512
6+
from cryptography.hazmat.primitives.hashes import SHA256, SHA384, SHA512
97

108
LENMET = {32: (16, SHA256), 48: (24, SHA384), 64: (32, SHA512)}
119

src/cryptojwt/jwk/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
from typing import List
66

77
from ..exception import UnsupportedAlgorithm
8-
from ..utils import as_bytes
9-
from ..utils import as_unicode
10-
from ..utils import b64e
11-
from ..utils import base64url_to_long
8+
from ..utils import as_bytes, as_unicode, b64e, base64url_to_long
129
from .utils import DIGEST_HASH
1310

1411
USE = {"sign": "sig", "decrypt": "enc", "encrypt": "enc", "verify": "sig"}

0 commit comments

Comments
 (0)