Skip to content

Commit 69cd381

Browse files
authored
Upgrade to isort 5 and adjust configurations (jpadilla#533)
With isort 5, asottile/seed-isort-config is deprecated and unnecessary. The official isort main repo now has a pre-commit hook file. isort is now better at recognizing first party and third party packages. isort can now handle imports inside blocks, files have been updated. isort now supports "profiles" for simpler configuration.
1 parent 5fc33b2 commit 69cd381

File tree

5 files changed

+27
-38
lines changed

5 files changed

+27
-38
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,10 @@ repos:
1111
- id: flake8
1212
language_version: python3.8
1313

14-
- repo: https://github.com/asottile/seed-isort-config
15-
rev: v1.9.4
16-
hooks:
17-
- id: seed-isort-config
18-
19-
- repo: https://github.com/pre-commit/mirrors-isort
20-
rev: v4.3.21
14+
- repo: https://github.com/PyCQA/isort
15+
rev: 5.6.4
2116
hooks:
2217
- id: isort
23-
additional_dependencies: [toml]
24-
language_version: python3.8
2518

2619
- repo: https://github.com/pre-commit/pre-commit-hooks
2720
rev: v2.4.0

jwt/algorithms.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,32 @@
1515
)
1616

1717
try:
18+
import cryptography.exceptions
19+
from cryptography.exceptions import InvalidSignature
1820
from cryptography.hazmat.primitives import hashes
19-
from cryptography.hazmat.primitives.serialization import (
20-
load_pem_private_key,
21-
load_pem_public_key,
22-
load_ssh_public_key,
21+
from cryptography.hazmat.primitives.asymmetric import ec, padding
22+
from cryptography.hazmat.primitives.asymmetric.ec import (
23+
EllipticCurvePrivateKey,
24+
EllipticCurvePublicKey,
25+
)
26+
from cryptography.hazmat.primitives.asymmetric.ed25519 import (
27+
Ed25519PrivateKey,
28+
Ed25519PublicKey,
2329
)
2430
from cryptography.hazmat.primitives.asymmetric.rsa import (
2531
RSAPrivateKey,
26-
RSAPublicKey,
2732
RSAPrivateNumbers,
33+
RSAPublicKey,
2834
RSAPublicNumbers,
29-
rsa_recover_prime_factors,
3035
rsa_crt_dmp1,
3136
rsa_crt_dmq1,
3237
rsa_crt_iqmp,
38+
rsa_recover_prime_factors,
3339
)
34-
from cryptography.hazmat.primitives.asymmetric.ec import (
35-
EllipticCurvePrivateKey,
36-
EllipticCurvePublicKey,
37-
)
38-
from cryptography.hazmat.primitives.asymmetric import ec, padding
39-
from cryptography.exceptions import InvalidSignature
40-
41-
import cryptography.exceptions
42-
from cryptography.hazmat.primitives.asymmetric.ed25519 import (
43-
Ed25519PrivateKey,
44-
Ed25519PublicKey,
40+
from cryptography.hazmat.primitives.serialization import (
41+
load_pem_private_key,
42+
load_pem_public_key,
43+
load_ssh_public_key,
4544
)
4645
from cryptography.utils import int_from_bytes
4746

pyproject.toml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ line-length = 79
2020

2121

2222
[tool.isort]
23-
atomic=true
24-
force_grid_wrap=0
25-
include_trailing_comma=true
26-
multi_line_output=3
27-
use_parentheses=true
28-
combine_as_imports=true
29-
30-
known_first_party="jwt"
31-
known_third_party=["pytest", "requests_mock", "setuptools", "sphinx_rtd_theme"]
23+
profile = "black"
24+
atomic = true
25+
combine_as_imports = true
26+
line_length = 79

tests/keys/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def load_hmac_key():
2121

2222
try:
2323
from cryptography.hazmat.primitives.asymmetric import ec
24+
2425
from jwt.algorithms import RSAAlgorithm
2526

2627
has_crypto = True

tests/test_algorithms.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212

1313
try:
1414
from jwt.algorithms import (
15-
RSAAlgorithm,
1615
ECAlgorithm,
17-
RSAPSSAlgorithm,
1816
Ed25519Algorithm,
17+
RSAAlgorithm,
18+
RSAPSSAlgorithm,
1919
)
20-
from .keys import load_rsa_pub_key, load_ec_pub_key_p_521
20+
21+
from .keys import load_ec_pub_key_p_521, load_rsa_pub_key
2122

2223
has_crypto = True
2324
except ImportError:

0 commit comments

Comments
 (0)