1- import sys
2- from typing import (
3- Any , AnyStr , Callable , IO , Iterable , Optional , Type , TypeVar , Union ,
4- overload )
1+ from collections .abc import Callable , Iterable
2+ from typing import Any , AnyStr , IO , typeVar , overload
3+ from _typeshed import GenericPath , Self , StrOrBytesPath
54
65from lxml .etree import _Element
76
8- from xmlsec import constants , template , tree
97from xmlsec .constants import __KeyData as KeyData , __Transform as Transform
108
11- if sys .version_info >= (3 , 6 ):
12- from os import PathLike
13- from pathlib import PurePath
14-
15- _Path = Union [str , bytes , PurePath , PathLike [str ], PathLike [bytes ]]
16- elif sys .version_info >= (3 , 4 ):
17- from pathlib import PurePath
18-
19- _Path = Union [str , bytes , PurePath ]
20- else :
21- _Path = Union [str , bytes ]
22-
23- _E = TypeVar ('_E' , bound = _Element )
24- _K = TypeVar ('_K' , bound = Key )
9+ _E = typeVar ('_E' , bound = _Element )
2510
2611def enable_debug_trace (enabled : bool = ...) -> None : ...
2712def init () -> None : ...
2813def shutdown () -> None : ...
2914def cleanup_callbacks () -> None : ...
3015def register_default_callbacks () -> None : ...
3116def register_callbacks (
32- input_match_callback : Callable [[bytes ], bool ],
33- input_open_callback : Callable [[bytes ], Any ],
34- input_read_callback : Callable [[Any , memoryview ], int ],
35- input_close_callback : Callable [[Any ], None ],
17+ input_match_callback : Callable [[bytes ], bool ],
18+ input_open_callback : Callable [[bytes ], Any ],
19+ input_read_callback : Callable [[Any , memoryview ], int ],
20+ input_close_callback : Callable [[Any ], None ],
3621) -> None : ...
3722@overload
3823def base64_default_line_size () -> int : ...
3924@overload
4025def base64_default_line_size (size : int ) -> None : ...
4126
4227class EncryptionContext :
43- key : Optional [ Key ]
44- def __init__ (self , manager : Optional [ KeysManager ] = None ) -> None : ...
28+ key : Key | None
29+ def __init__ (self , manager : KeysManager | None = ... ) -> None : ...
4530 def decrypt (self , node : _Element ) -> _Element : ...
4631 def encrypt_binary (self , template : _E , data : bytes ) -> _E : ...
4732 def encrypt_uri (self , template : _E , uri : str ) -> _E : ...
@@ -54,30 +39,30 @@ class InternalError(Error): ...
5439class Key :
5540 name : str
5641 @classmethod
57- def from_binary_data (cls : Type [ _K ], klass : KeyData , data : AnyStr ) -> _K : ...
42+ def from_binary_data (cls : type [ Self ], klass : KeyData , data : AnyStr ) -> Self : ...
5843 @classmethod
59- def from_binary_file (cls : Type [ _K ], klass : KeyData , filename : _Path ) -> _K : ...
44+ def from_binary_file (cls : type [ Self ], klass : KeyData , filename : StrOrBytesPath ) -> Self : ...
6045 @classmethod
61- def from_file (cls : Type [ _K ], file : Union [ _Path , IO [AnyStr ]] , format : int , password : Optional [ str ] = ...) -> _K : ...
46+ def from_file (cls : type [ Self ], file : GenericPath | IO [AnyStr ], format : int , password : str | None = ...) -> Self : ...
6247 @classmethod
63- def from_memory (cls : Type [ _K ], data : AnyStr , format : int , password : Optional [ str ] = ...) -> _K : ...
48+ def from_memory (cls : type [ Self ], data : AnyStr , format : int , password : str | None = ...) -> Self : ...
6449 @classmethod
65- def generate (cls : Type [ _K ], klass : KeyData , size : int , type : int ) -> _K : ...
66- def load_cert_from_file (self , file : Union [ _Path , IO [AnyStr ] ], format : int ) -> None : ...
50+ def generate (cls : type [ Self ], klass : KeyData , size : int , type : int ) -> Self : ...
51+ def load_cert_from_file (self , file : GenericPath | IO [AnyStr ], format : int ) -> None : ...
6752 def load_cert_from_memory (self , data : AnyStr , format : int ) -> None : ...
68- def __copy__ (self : _K ) -> _K : ...
69- def __deepcopy__ (self : _K ) -> _K : ...
53+ def __copy__ (self : Self ) -> Self : ...
54+ def __deepcopy__ (self : Self ) -> Self : ...
7055
7156class KeysManager :
7257 def add_key (self , key : Key ) -> None : ...
73- def load_cert (self , filename : _Path , format : int , type : int ) -> None : ...
58+ def load_cert (self , filename : StrOrBytesPath , format : int , type : int ) -> None : ...
7459 def load_cert_from_memory (self , data : AnyStr , format : int , type : int ) -> None : ...
7560
7661class SignatureContext :
77- key : Optional [ Key ]
62+ key : Key | None
7863 def enable_reference_transform (self , transform : Transform ) -> None : ...
7964 def enable_signature_transform (self , transform : Transform ) -> None : ...
80- def register_id (self , node : _Element , id_attr : str = "ID" , id_ns : Optional [ str ] = None ) -> None : ...
65+ def register_id (self , node : _Element , id_attr : str = ... , id_ns : str | None = ... ) -> None : ...
8166 def set_enabled_key_data (self , keydata_list : Iterable [KeyData ]) -> None : ...
8267 def sign (self , node : _Element ) -> None : ...
8368 def sign_binary (self , bytes : bytes , transform : Transform ) -> bytes : ...
0 commit comments