From 9695f4c1d153ed8bf2b9ba0ef232c3a90889a1be Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 16:09:41 +0600 Subject: [pre-commit.ci] pre-commit autoupdate (#855) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- jwt/algorithms.py | 1 - jwt/jwk_set_cache.py | 1 - tests/test_algorithms.py | 6 +++--- tests/test_api_jwk.py | 10 ---------- tests/test_api_jws.py | 1 - tests/test_api_jwt.py | 1 - 7 files changed, 4 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ec0cd9..ae4cca8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black args: ["--target-version=py37"] diff --git a/jwt/algorithms.py b/jwt/algorithms.py index 80d303c..277f940 100644 --- a/jwt/algorithms.py +++ b/jwt/algorithms.py @@ -475,7 +475,6 @@ if has_crypto: @staticmethod def to_jwk(key_obj): - if isinstance(key_obj, EllipticCurvePrivateKey): public_numbers = key_obj.public_key().public_numbers() elif isinstance(key_obj, EllipticCurvePublicKey): diff --git a/jwt/jwk_set_cache.py b/jwt/jwk_set_cache.py index 1b2465c..2432563 100644 --- a/jwt/jwk_set_cache.py +++ b/jwt/jwk_set_cache.py @@ -23,7 +23,6 @@ class JWKSetCache: return self.jwk_set_with_timestamp.get_jwk_set() def is_expired(self) -> bool: - return ( self.jwk_set_with_timestamp is not None and self.lifespan > -1 diff --git a/tests/test_algorithms.py b/tests/test_algorithms.py index 3ace425..1533b5d 100644 --- a/tests/test_algorithms.py +++ b/tests/test_algorithms.py @@ -169,7 +169,7 @@ class TestAlgorithms: "P-521": ECAlgorithm.SHA512, "secp256k1": ECAlgorithm.SHA256, } - for (curve, hash) in tests.items(): + for curve, hash in tests.items(): algo = ECAlgorithm(hash) with open(key_path(f"jwk_ec_pub_{curve}.json")) as keyfile: @@ -236,7 +236,7 @@ class TestAlgorithms: ) # EC private key length invalid - for (curve, point) in valid_points.items(): + for curve, point in valid_points.items(): with pytest.raises(InvalidKeyError): algo.from_jwk( f'{{"kty": "EC", "crv": "{curve}", "x": "{point["x"]}", "y": "{point["y"]}", "d": "dGVzdA=="}}' @@ -318,7 +318,7 @@ class TestAlgorithms: "P-521": ECAlgorithm.SHA512, "secp256k1": ECAlgorithm.SHA256, } - for (curve, hash) in tests.items(): + for curve, hash in tests.items(): algo = ECAlgorithm(hash) with open(key_path(f"jwk_ec_pub_{curve}.json")) as keyfile: diff --git a/tests/test_api_jwk.py b/tests/test_api_jwk.py index f04f575..4754db6 100644 --- a/tests/test_api_jwk.py +++ b/tests/test_api_jwk.py @@ -57,7 +57,6 @@ class TestPyJWK: @crypto_required def test_should_load_key_without_alg_from_dict(self): - with open(key_path("jwk_rsa_pub.json")) as keyfile: key_data = json.loads(keyfile.read()) @@ -69,7 +68,6 @@ class TestPyJWK: @crypto_required def test_should_load_key_from_dict_with_algorithm(self): - with open(key_path("jwk_rsa_pub.json")) as keyfile: key_data = json.loads(keyfile.read()) @@ -81,7 +79,6 @@ class TestPyJWK: @crypto_required def test_should_load_key_ec_p256_from_dict(self): - with open(key_path("jwk_ec_pub_P-256.json")) as keyfile: key_data = json.loads(keyfile.read()) @@ -93,7 +90,6 @@ class TestPyJWK: @crypto_required def test_should_load_key_ec_p384_from_dict(self): - with open(key_path("jwk_ec_pub_P-384.json")) as keyfile: key_data = json.loads(keyfile.read()) @@ -105,7 +101,6 @@ class TestPyJWK: @crypto_required def test_should_load_key_ec_p521_from_dict(self): - with open(key_path("jwk_ec_pub_P-521.json")) as keyfile: key_data = json.loads(keyfile.read()) @@ -117,7 +112,6 @@ class TestPyJWK: @crypto_required def test_should_load_key_ec_secp256k1_from_dict(self): - with open(key_path("jwk_ec_pub_secp256k1.json")) as keyfile: key_data = json.loads(keyfile.read()) @@ -129,7 +123,6 @@ class TestPyJWK: @crypto_required def test_should_load_key_hmac_from_dict(self): - with open(key_path("jwk_hmac.json")) as keyfile: key_data = json.loads(keyfile.read()) @@ -141,7 +134,6 @@ class TestPyJWK: @crypto_required def test_should_load_key_hmac_without_alg_from_dict(self): - with open(key_path("jwk_hmac.json")) as keyfile: key_data = json.loads(keyfile.read()) @@ -154,7 +146,6 @@ class TestPyJWK: @crypto_required def test_should_load_key_okp_without_alg_from_dict(self): - with open(key_path("jwk_okp_pub_Ed25519.json")) as keyfile: key_data = json.loads(keyfile.read()) @@ -165,7 +156,6 @@ class TestPyJWK: @crypto_required def test_from_dict_should_throw_exception_if_arg_is_invalid(self): - with open(key_path("jwk_rsa_pub.json")) as keyfile: valid_rsa_pub = json.loads(keyfile.read()) with open(key_path("jwk_ec_pub_P-256.json")) as keyfile: diff --git a/tests/test_api_jws.py b/tests/test_api_jws.py index fe6c2d4..2929215 100644 --- a/tests/test_api_jws.py +++ b/tests/test_api_jws.py @@ -158,7 +158,6 @@ class TestJWS: assert str(exception) == "Invalid header string: must be a json object" def test_encode_algorithm_param_should_be_case_sensitive(self, jws, payload): - jws.encode(payload, "secret", algorithm="HS256") with pytest.raises(NotImplementedError) as context: diff --git a/tests/test_api_jwt.py b/tests/test_api_jwt.py index 24ed240..3c08ea5 100644 --- a/tests/test_api_jwt.py +++ b/tests/test_api_jwt.py @@ -160,7 +160,6 @@ class TestJWT: assert str(exception) == "Invalid claim format in token" def test_encode_bad_type(self, jwt): - types = ["string", tuple(), list(), 42, set()] for t in types: -- cgit v1.2.1