1414USE = {"sign" : "sig" , "decrypt" : "enc" , "encrypt" : "enc" , "verify" : "sig" }
1515
1616
17- class JWK ( object ) :
17+ class JWK :
1818 """
1919 Basic JSON Web key class. Jason Web keys are described in
2020 RFC 7517 (https://tools.ietf.org/html/rfc7517).
@@ -56,7 +56,7 @@ def __init__(
5656 "ECDH-ES+A192KW" ,
5757 "ECDH-ES+A256KW" ,
5858 ]:
59- raise UnsupportedAlgorithm ("Unknown algorithm: {}" . format ( alg ) )
59+ raise UnsupportedAlgorithm (f "Unknown algorithm: { alg } " )
6060 elif use == "sig" :
6161 # The list comes from https://tools.ietf.org/html/rfc7518#page-6
6262 # Should map against SIGNER_ALGS in cryptojwt.jws.jws
@@ -79,7 +79,7 @@ def __init__(
7979 "Ed448" ,
8080 "none" ,
8181 ]:
82- raise UnsupportedAlgorithm ("Unknown algorithm: {}" . format ( alg ) )
82+ raise UnsupportedAlgorithm (f "Unknown algorithm: { alg } " )
8383 else : # potentially used both for encryption and signing
8484 if alg not in [
8585 "HS256" ,
@@ -110,7 +110,7 @@ def __init__(
110110 "ECDH-ES+A192KW" ,
111111 "ECDH-ES+A256KW" ,
112112 ]:
113- raise UnsupportedAlgorithm ("Unknown algorithm: {}" . format ( alg ) )
113+ raise UnsupportedAlgorithm (f "Unknown algorithm: { alg } " )
114114 self .alg = alg
115115
116116 if isinstance (use , str ):
@@ -271,7 +271,7 @@ def thumbprint(self, hash_function, members=None):
271271 else :
272272 if isinstance (_val , bytes ):
273273 _val = as_unicode (_val )
274- _se .append ('"{}":{}' . format ( elem , json .dumps (_val )) )
274+ _se .append (f '"{ elem } ":{ json .dumps (_val )} ' )
275275 _json = "{{{}}}" .format ("," .join (_se ))
276276
277277 return b64e (DIGEST_HASH [hash_function ](_json ))
@@ -298,7 +298,7 @@ def update(self):
298298 pass
299299
300300 def key_len (self ):
301- raise NotImplemented
301+ raise NotImplementedError
302302
303303
304304def pems_to_x5c (cert_chain ):
@@ -360,7 +360,7 @@ def certificate_fingerprint(der, hash="sha256"):
360360
361361
362362def pem_hash (pem_file ):
363- with open (pem_file , "r" ) as fp :
363+ with open (pem_file ) as fp :
364364 pem = fp .read ()
365365
366366 der = ssl .PEM_cert_to_DER_cert (pem )
0 commit comments