@@ -42,15 +42,15 @@ def import_from_dict(cls, value: DictKey) -> t.Any:
4242
4343 @classmethod
4444 @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 :
4646 pass
4747
4848 @staticmethod
4949 def as_bytes (
5050 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 ,
5454 ) -> bytes :
5555 raise NotImplementedError ()
5656
@@ -88,7 +88,7 @@ def __init__(
8888 self ,
8989 raw_value : NativePrivateKey | NativePublicKey ,
9090 original_value : t .Any ,
91- parameters : t . Optional [ KeyParameters ] = None ,
91+ parameters : KeyParameters | None = None ,
9292 ):
9393 self ._raw_value = raw_value
9494 self .original_value = original_value
@@ -160,7 +160,7 @@ def public_key(self) -> NativePublicKey:
160160 raise NotImplementedError ()
161161
162162 @property
163- def private_key (self ) -> t . Optional [ NativePrivateKey ] :
163+ def private_key (self ) -> NativePrivateKey | None :
164164 raise NotImplementedError ()
165165
166166 def thumbprint (self ) -> str :
@@ -177,7 +177,7 @@ def thumbprint_uri(self) -> str:
177177 value = self .thumbprint ()
178178 return concat_thumbprint_uri (value , self .thumbprint_digest_method )
179179
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 :
181181 """Output this key to a JWK format (in dict). By default, it will return
182182 the ``dict_value`` of this key.
183183
@@ -270,8 +270,8 @@ def validate_dict_key(cls, data: DictKey) -> None:
270270 def import_key (
271271 cls : t .Type [GenericKey ],
272272 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 ,
275275 ) -> GenericKey :
276276 if isinstance (value , dict ):
277277 cls .validate_dict_key (value )
@@ -285,7 +285,7 @@ def import_key(
285285 def generate_key (
286286 cls : t .Type [GenericKey ],
287287 size_or_crv : t .Any ,
288- parameters : t . Optional [ KeyParameters ] = None ,
288+ parameters : KeyParameters | None = None ,
289289 private : bool = True ,
290290 auto_kid : bool = False ,
291291 ) -> GenericKey :
@@ -321,16 +321,16 @@ def raw_value(self) -> t.Union[NativePublicKey, NativePrivateKey]:
321321
322322 def as_bytes (
323323 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 ,
327327 ) -> bytes :
328328 return self .binding .as_bytes (self , encoding , private , password )
329329
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 :
331331 return self .as_bytes (private = private , password = password )
332332
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 :
334334 return self .as_bytes (encoding = "DER" , private = private , password = password )
335335
336336
0 commit comments