Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 5, 2024
1 parent 041b475 commit b0b386f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
16 changes: 12 additions & 4 deletions jwt/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ def prepare_key(self, key: AllowedRSAKeys | str | bytes) -> AllowedRSAKeys:
try:
return cast(RSAPublicKey, load_pem_public_key(key_bytes))
except (ValueError, UnsupportedAlgorithm):
raise InvalidKeyError("Could not parse the provided public key.") from None
raise InvalidKeyError(
"Could not parse the provided public key."
) from None

@overload
@staticmethod
Expand Down Expand Up @@ -623,17 +625,23 @@ def from_jwk(jwk: str | JWKDict) -> AllowedECKeys:
if len(x) == len(y) == 32:
curve_obj = SECP256R1()
else:
raise InvalidKeyError("Coords should be 32 bytes for curve P-256") from None
raise InvalidKeyError(
"Coords should be 32 bytes for curve P-256"
) from None
elif curve == "P-384":
if len(x) == len(y) == 48:
curve_obj = SECP384R1()
else:
raise InvalidKeyError("Coords should be 48 bytes for curve P-384") from None
raise InvalidKeyError(
"Coords should be 48 bytes for curve P-384"
) from None
elif curve == "P-521":
if len(x) == len(y) == 66:
curve_obj = SECP521R1()
else:
raise InvalidKeyError("Coords should be 66 bytes for curve P-521") from None
raise InvalidKeyError(
"Coords should be 66 bytes for curve P-521"
) from None
elif curve == "secp256k1":
if len(x) == len(y) == 32:
curve_obj = SECP256K1()
Expand Down
8 changes: 6 additions & 2 deletions jwt/api_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ def _validate_iat(
try:
iat = int(payload["iat"])
except ValueError:
raise InvalidIssuedAtError("Issued At claim (iat) must be an integer.") from None
raise InvalidIssuedAtError(
"Issued At claim (iat) must be an integer."
) from None
if iat > (now + leeway):
raise ImmatureSignatureError("The token is not yet valid (iat)")

Expand All @@ -296,7 +298,9 @@ def _validate_exp(
try:
exp = int(payload["exp"])
except ValueError:
raise DecodeError("Expiration Time claim (exp) must be an integer.") from None
raise DecodeError(
"Expiration Time claim (exp) must be an integer."
) from None

if exp <= (now - leeway):
raise ExpiredSignatureError("Signature has expired")
Expand Down

0 comments on commit b0b386f

Please sign in to comment.