Skip to content

Commit ef883bb

Browse files
AJolhe-FISamanjolhe
authored andcommitted
fix: resolve MyPy type checking errors in RSA and OKP algorithms
1 parent abad2e6 commit ef883bb

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

jwt/algorithms.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -470,24 +470,24 @@ def prepare_key(self, key: AllowedRSAKeys | str | bytes) -> AllowedRSAKeys:
470470
if key_bytes.startswith(b"ssh-rsa"):
471471
public_key: PublicKeyTypes = load_ssh_public_key(key_bytes)
472472
self.check_crypto_key_type(public_key)
473-
rsa_key = cast(RSAPublicKey, public_key)
474-
self._validate_rsa_key_size(rsa_key)
475-
return rsa_key
473+
rsa_public_key = cast(RSAPublicKey, public_key)
474+
self._validate_rsa_key_size(rsa_public_key)
475+
return rsa_public_key
476476
else:
477477
private_key: PrivateKeyTypes = load_pem_private_key(
478478
key_bytes, password=None
479479
)
480480
self.check_crypto_key_type(private_key)
481-
rsa_key = cast(RSAPrivateKey, private_key)
482-
self._validate_rsa_key_size(rsa_key)
483-
return rsa_key
481+
rsa_private_key = cast(RSAPrivateKey, private_key)
482+
self._validate_rsa_key_size(rsa_private_key)
483+
return rsa_private_key
484484
except ValueError:
485485
try:
486486
public_key = load_pem_public_key(key_bytes)
487487
self.check_crypto_key_type(public_key)
488-
rsa_key = cast(RSAPublicKey, public_key)
489-
self._validate_rsa_key_size(rsa_key)
490-
return rsa_key
488+
rsa_public_key = cast(RSAPublicKey, public_key)
489+
self._validate_rsa_key_size(rsa_public_key)
490+
return rsa_public_key
491491
except (ValueError, UnsupportedAlgorithm):
492492
raise InvalidKeyError(
493493
"Could not parse the provided public key."
@@ -871,7 +871,7 @@ def __init__(self, **kwargs: Any) -> None:
871871
def prepare_key(self, key: AllowedOKPKeys | str | bytes) -> AllowedOKPKeys:
872872
if not isinstance(key, (str, bytes)):
873873
self.check_crypto_key_type(key)
874-
return cast("AllowedOKPKeys", key)
874+
return key
875875

876876
key_str = key.decode("utf-8") if isinstance(key, bytes) else key
877877
key_bytes = key.encode("utf-8") if isinstance(key, str) else key

0 commit comments

Comments
 (0)