@@ -42,15 +42,15 @@ def import_from_dict(cls, value: DictKey) -> t.Any:
42
42
43
43
@classmethod
44
44
@abstractmethod
45
- def import_from_bytes (cls , value : bytes , password : t .Optional [ t . Any ] = None ) -> t .Any :
45
+ def import_from_bytes (cls , value : bytes , password : t .Any = None ) -> t .Any :
46
46
pass
47
47
48
48
@staticmethod
49
49
def as_bytes (
50
50
key : GenericKey ,
51
- encoding : t .Optional [ t . Literal ["PEM" , "DER" ]] = None ,
52
- private : t . Optional [ bool ] = None ,
53
- password : t . Optional [ str ] = None ,
51
+ encoding : t .Literal ["PEM" , "DER" ] | None = None ,
52
+ private : bool | None = None ,
53
+ password : str | None = None ,
54
54
) -> bytes :
55
55
raise NotImplementedError ()
56
56
@@ -88,7 +88,7 @@ def __init__(
88
88
self ,
89
89
raw_value : NativePrivateKey | NativePublicKey ,
90
90
original_value : t .Any ,
91
- parameters : t . Optional [ KeyParameters ] = None ,
91
+ parameters : KeyParameters | None = None ,
92
92
):
93
93
self ._raw_value = raw_value
94
94
self .original_value = original_value
@@ -160,7 +160,7 @@ def public_key(self) -> NativePublicKey:
160
160
raise NotImplementedError ()
161
161
162
162
@property
163
- def private_key (self ) -> t . Optional [ NativePrivateKey ] :
163
+ def private_key (self ) -> NativePrivateKey | None :
164
164
raise NotImplementedError ()
165
165
166
166
def thumbprint (self ) -> str :
@@ -177,7 +177,7 @@ def thumbprint_uri(self) -> str:
177
177
value = self .thumbprint ()
178
178
return concat_thumbprint_uri (value , self .thumbprint_digest_method )
179
179
180
- def as_dict (self , private : t . Optional [ bool ] = None , ** params : t .Any ) -> DictKey :
180
+ def as_dict (self , private : bool | None = None , ** params : t .Any ) -> DictKey :
181
181
"""Output this key to a JWK format (in dict). By default, it will return
182
182
the ``dict_value`` of this key.
183
183
@@ -270,8 +270,8 @@ def validate_dict_key(cls, data: DictKey) -> None:
270
270
def import_key (
271
271
cls : t .Type [GenericKey ],
272
272
value : AnyKey ,
273
- parameters : t . Optional [ KeyParameters ] = None ,
274
- password : t .Optional [ t . Any ] = None ,
273
+ parameters : KeyParameters | None = None ,
274
+ password : t .Any = None ,
275
275
) -> GenericKey :
276
276
if isinstance (value , dict ):
277
277
cls .validate_dict_key (value )
@@ -285,7 +285,7 @@ def import_key(
285
285
def generate_key (
286
286
cls : t .Type [GenericKey ],
287
287
size_or_crv : t .Any ,
288
- parameters : t . Optional [ KeyParameters ] = None ,
288
+ parameters : KeyParameters | None = None ,
289
289
private : bool = True ,
290
290
auto_kid : bool = False ,
291
291
) -> GenericKey :
@@ -321,16 +321,16 @@ def raw_value(self) -> t.Union[NativePublicKey, NativePrivateKey]:
321
321
322
322
def as_bytes (
323
323
self ,
324
- encoding : t .Optional [ t . Literal ["PEM" , "DER" ]] = None ,
325
- private : t . Optional [ bool ] = None ,
326
- password : t . Optional [ str ] = None ,
324
+ encoding : t .Literal ["PEM" , "DER" ] | None = None ,
325
+ private : bool | None = None ,
326
+ password : str | None = None ,
327
327
) -> bytes :
328
328
return self .binding .as_bytes (self , encoding , private , password )
329
329
330
- def as_pem (self , private : t . Optional [ bool ] = None , password : t . Optional [ str ] = None ) -> bytes :
330
+ def as_pem (self , private : bool | None = None , password : str | None = None ) -> bytes :
331
331
return self .as_bytes (private = private , password = password )
332
332
333
- def as_der (self , private : t . Optional [ bool ] = None , password : t . Optional [ str ] = None ) -> bytes :
333
+ def as_der (self , private : bool | None = None , password : str | None = None ) -> bytes :
334
334
return self .as_bytes (encoding = "DER" , private = private , password = password )
335
335
336
336
0 commit comments