Skip to content

Commit

Permalink
Merge pull request #52 from jschlyter/isort
Browse files Browse the repository at this point in the history
isort everything
  • Loading branch information
rohe authored Jun 26, 2020
2 parents e8789c2 + 43af297 commit 08bf8e5
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ install:
- pip install codecov
- pip install tox
- pip install tox-travis
- pip install isort
script:
- isort --check --recursive src
- codecov --version
- tox
after_success:
Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[isort]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 88
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
fd.read(), re.MULTILINE).group(1)

tests_requires = ['responses', 'pytest']
tests_requires = ['responses', 'pytest', 'isort']

setup(
name="cryptojwt",
Expand Down
2 changes: 1 addition & 1 deletion src/cryptojwt/jwk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import ssl
from typing import List

from .utils import DIGEST_HASH
from ..exception import UnsupportedAlgorithm
from ..utils import as_bytes
from ..utils import as_unicode
from ..utils import b64e
from ..utils import base64url_to_long
from .utils import DIGEST_HASH

USE = {
'sign': 'sig',
Expand Down
2 changes: 1 addition & 1 deletion src/cryptojwt/jwk/rsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from ..exception import JWKESTException
from ..exception import SerializationNotPossible
from ..exception import UnsupportedKeyType
from ..utils import as_unicode
from ..utils import b64e
from ..utils import deser
from ..utils import long_to_base64
from ..utils import as_unicode
from . import JWK
from .asym import AsymmetricKey

Expand Down
6 changes: 2 additions & 4 deletions src/cryptojwt/jws/dsa.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.asymmetric.utils import \
decode_dss_signature
from cryptography.hazmat.primitives.asymmetric.utils import \
encode_dss_signature
from cryptography.hazmat.primitives.asymmetric.utils import decode_dss_signature
from cryptography.hazmat.primitives.asymmetric.utils import encode_dss_signature
from cryptography.utils import int_from_bytes
from cryptography.utils import int_to_bytes

Expand Down
17 changes: 9 additions & 8 deletions src/cryptojwt/jws/jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
import logging

from cryptojwt.jws.exception import JWSException
from .dsa import ECDSASigner
from .exception import FormatError
from .exception import NoSuitableSigningKeys
from .exception import SignerAlgError
from .hmac import HMACSigner
from .pss import PSSSigner
from .rsa import RSASigner
from .utils import alg2keytype

from ..exception import BadSignature
from ..exception import UnknownAlgorithm
from ..exception import WrongNumberOfParts
Expand All @@ -20,6 +13,14 @@
from ..utils import b64d_enc_dec
from ..utils import b64e_enc_dec
from ..utils import b64encode_item
from .dsa import ECDSASigner
from .exception import FormatError
from .exception import NoSuitableSigningKeys
from .exception import SignerAlgError
from .hmac import HMACSigner
from .pss import PSSSigner
from .rsa import RSASigner
from .utils import alg2keytype

try:
from builtins import str
Expand Down
1 change: 1 addition & 0 deletions src/cryptojwt/jwx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from cryptojwt.jwk import JWK
from cryptojwt.key_bundle import KeyBundle

from .exception import HeaderError
from .jwk.jwk import key_from_jwk_dict
from .jwk.rsa import RSAKey
Expand Down
1 change: 1 addition & 0 deletions src/cryptojwt/key_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from cryptojwt.jwk.ec import NIST2SEC
from cryptojwt.jwk.hmac import new_sym_key

from .exception import JWKException
from .exception import UnknownKeyType
from .exception import UnsupportedAlgorithm
Expand Down
8 changes: 4 additions & 4 deletions src/cryptojwt/key_issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
from .jws.utils import alg2keytype as jws_alg2keytype
from .key_bundle import KeyBundle
from .key_bundle import build_key_bundle
from .key_bundle import key_diff
from .key_bundle import update_key_bundle
from .utils import importer
from .utils import qualified_name

__author__ = 'Roland Hedberg'

from .key_bundle import key_diff
from .key_bundle import update_key_bundle

from .utils import importer

from .utils import qualified_name

logger = logging.getLogger(__name__)

Expand Down
5 changes: 4 additions & 1 deletion src/cryptojwt/key_jar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

from requests import request

from .exception import UnknownKeyType, KeyIOError, UpdateFailed, IssuerNotFound
from .exception import IssuerNotFound
from .exception import KeyIOError
from .exception import UnknownKeyType
from .exception import UpdateFailed
from .jwe.jwe import alg2keytype as jwe_alg2keytype
from .jws.utils import alg2keytype as jws_alg2keytype
from .key_bundle import KeyBundle
Expand Down
8 changes: 4 additions & 4 deletions src/cryptojwt/tools/jwtpeek.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import os
import sys

from cryptojwt.key_issuer import KeyIssuer
from pygments import highlight
from pygments.formatters.terminal import TerminalFormatter
from pygments.lexers.data import JsonLexer

from cryptojwt.jwe import jwe
from cryptojwt.jwk.hmac import SYMKey
Expand All @@ -16,10 +18,8 @@
from cryptojwt.jwk.rsa import import_rsa_key
from cryptojwt.jws import jws
from cryptojwt.key_bundle import KeyBundle
from cryptojwt.key_issuer import KeyIssuer
from cryptojwt.key_jar import KeyJar
from pygments import highlight
from pygments.formatters.terminal import TerminalFormatter
from pygments.lexers.data import JsonLexer

__author__ = 'roland'

Expand Down
1 change: 1 addition & 0 deletions src/cryptojwt/tools/keyconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Optional

from cryptography.hazmat.primitives import serialization

from cryptojwt.jwk import JWK
from cryptojwt.jwk.ec import ECKey
from cryptojwt.jwk.ec import import_private_key_from_file
Expand Down
1 change: 0 additions & 1 deletion src/cryptojwt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from cryptojwt.exception import BadSyntax


# ---------------------------------------------------------------------------
# Helper functions

Expand Down
1 change: 1 addition & 0 deletions tests/invalid_ecdh.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from cryptojwt.jwe import JWE_EC
from cryptojwt.jwe import factory
from cryptojwt.jwk import ECKey
Expand Down
2 changes: 1 addition & 1 deletion tests/test_02_jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from cryptojwt.jwk import certificate_fingerprint
from cryptojwt.jwk import pem_hash
from cryptojwt.jwk import pems_to_x5c
from cryptojwt.jwk.ec import ECKey
from cryptojwt.jwk.ec import NIST2SEC
from cryptojwt.jwk.ec import ECKey
from cryptojwt.jwk.hmac import SYMKey
from cryptojwt.jwk.hmac import new_sym_key
from cryptojwt.jwk.hmac import sha256_digest
Expand Down
5 changes: 3 additions & 2 deletions tests/test_04_key_jar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import pytest

from cryptojwt.exception import JWKESTException, IssuerNotFound
from cryptojwt.exception import IssuerNotFound
from cryptojwt.exception import JWKESTException
from cryptojwt.jwe.jwenc import JWEnc
from cryptojwt.jws.jws import JWS
from cryptojwt.jws.jws import factory
Expand All @@ -15,10 +16,10 @@
from cryptojwt.key_jar import KeyJar
from cryptojwt.key_jar import build_keyjar
from cryptojwt.key_jar import init_key_jar
from cryptojwt.key_jar import rotate_keys

__author__ = 'Roland Hedberg'

from cryptojwt.key_jar import rotate_keys

BASE_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__),
"test_keys"))
Expand Down
1 change: 1 addition & 0 deletions tests/test_05_jwx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os

import pytest

from cryptojwt.jwk.rsa import RSAKey
from cryptojwt.jwx import JWx

Expand Down
2 changes: 1 addition & 1 deletion tests/test_06_jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from cryptojwt.jws.exception import NoSuitableSigningKeys
from cryptojwt.jws.exception import SignerAlgError
from cryptojwt.jws.jws import JWS
from cryptojwt.jws.jws import JWSig
from cryptojwt.jws.jws import SIGNER_ALGS
from cryptojwt.jws.jws import JWSig
from cryptojwt.jws.jws import factory
from cryptojwt.jws.rsa import RSASigner
from cryptojwt.jws.utils import left_hash
Expand Down
1 change: 1 addition & 0 deletions tests/test_07_jwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pytest
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import ec

from cryptojwt.exception import BadSyntax
from cryptojwt.exception import HeaderError
from cryptojwt.exception import MissingKey
Expand Down
3 changes: 2 additions & 1 deletion tests/test_09_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import pytest

from cryptojwt.exception import JWKESTException, IssuerNotFound
from cryptojwt.exception import IssuerNotFound
from cryptojwt.exception import JWKESTException
from cryptojwt.jws.exception import NoSuitableSigningKeys
from cryptojwt.jwt import JWT
from cryptojwt.jwt import pick_key
Expand Down
3 changes: 2 additions & 1 deletion tests/test_10_jwk_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from cryptojwt.jwk.ec import new_ec_key
from cryptojwt.jwk.hmac import SYMKey
from cryptojwt.jwk.rsa import new_rsa_key
from cryptojwt.jwk.wrap import wrap_key, unwrap_key
from cryptojwt.jwk.wrap import unwrap_key
from cryptojwt.jwk.wrap import wrap_key

__author__ = 'jschlyter'

Expand Down
1 change: 1 addition & 0 deletions tests/test_20_jws.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import pytest
import test_vector

from cryptojwt import utils
from cryptojwt.exception import JWKESTException
from cryptojwt.jwk.jwk import key_from_jwk_dict
Expand Down

0 comments on commit 08bf8e5

Please sign in to comment.