11from _typeshed import Incomplete
22from collections .abc import Generator
3- from typing import overload
3+ from typing import Literal , overload
44
5- k : str
6- v : str | int
7-
8- def htmlentityreplace_errors (exc : Exception ) -> tuple [str | bytes , int ]: ...
9- @overload
10- def serialize (input , tree : str = "etree" , encoding : None = None , ** serializer_opts ) -> str : ...
5+ def htmlentityreplace_errors (exc : UnicodeError ) -> tuple [str | bytes , int ]: ...
116@overload
12- def serialize (input , tree : str , encoding : str , ** serializer_opts ) -> bytes : ...
7+ def serialize (
8+ input ,
9+ tree : Literal ["dom" , "genshi" , "lxml" , "etree" ] = "etree" ,
10+ encoding : Literal ["" ] | None = None ,
11+ * ,
12+ quote_attr_values : Literal ["legacy" , "spec" , "always" ] = "legacy" ,
13+ quote_char : str = '"' ,
14+ use_best_quote_char : bool = ..., # default value depends on whether quote_char was passed
15+ omit_optional_tags : bool = True ,
16+ minimize_boolean_attributes : bool = True ,
17+ use_trailing_solidus : bool = False ,
18+ space_before_trailing_solidus : bool = True ,
19+ escape_lt_in_attrs : bool = False ,
20+ escape_rcdata : bool = False ,
21+ resolve_entities : bool = True ,
22+ alphabetical_attributes : bool = False ,
23+ inject_meta_charset : bool = True ,
24+ strip_whitespace : bool = False ,
25+ sanitize : bool = False ,
26+ ) -> str : ...
1327@overload
14- def serialize (input , * , encoding : str , ** serializer_opts ) -> bytes : ...
28+ def serialize (
29+ input ,
30+ tree : Literal ["dom" , "genshi" , "lxml" , "etree" ] = "etree" ,
31+ encoding : str = ...,
32+ * ,
33+ quote_attr_values : Literal ["legacy" , "spec" , "always" ] = "legacy" ,
34+ quote_char : str = '"' ,
35+ use_best_quote_char : bool = ..., # default value depends on whether quote_char was passed
36+ omit_optional_tags : bool = True ,
37+ minimize_boolean_attributes : bool = True ,
38+ use_trailing_solidus : bool = False ,
39+ space_before_trailing_solidus : bool = True ,
40+ escape_lt_in_attrs : bool = False ,
41+ escape_rcdata : bool = False ,
42+ resolve_entities : bool = True ,
43+ alphabetical_attributes : bool = False ,
44+ inject_meta_charset : bool = True ,
45+ strip_whitespace : bool = False ,
46+ sanitize : bool = False ,
47+ ) -> bytes : ...
1548
1649class HTMLSerializer :
17- quote_attr_values : str
50+ quote_attr_values : Literal [ "legacy" , "spec" , "always" ]
1851 quote_char : str
1952 use_best_quote_char : bool
2053 omit_optional_tags : bool
@@ -28,15 +61,38 @@ class HTMLSerializer:
2861 inject_meta_charset : bool
2962 strip_whitespace : bool
3063 sanitize : bool
31- options : Incomplete
32- errors : Incomplete
64+ options : tuple [ str , ...]
65+ errors : list [ Incomplete ]
3366 strict : bool
34- def __init__ (self , ** kwargs ) -> None : ...
35- def encode (self , string ): ...
36- def encodeStrict (self , string ): ...
37- encoding : Incomplete
38- def serialize (self , treewalker , encoding = None ) -> Generator [Incomplete ]: ...
39- def render (self , treewalker , encoding = None ): ...
40- def serializeError (self , data : str = "XXX ERROR MESSAGE NEEDED" ) -> None : ...
67+ def __init__ (
68+ self ,
69+ * ,
70+ quote_attr_values : Literal ["legacy" , "spec" , "always" ] = "legacy" ,
71+ quote_char : str = '"' ,
72+ use_best_quote_char : bool = ..., # default value depends on whether quote_char was passed
73+ omit_optional_tags : bool = True ,
74+ minimize_boolean_attributes : bool = True ,
75+ use_trailing_solidus : bool = False ,
76+ space_before_trailing_solidus : bool = True ,
77+ escape_lt_in_attrs : bool = False ,
78+ escape_rcdata : bool = False ,
79+ resolve_entities : bool = True ,
80+ alphabetical_attributes : bool = False ,
81+ inject_meta_charset : bool = True ,
82+ strip_whitespace : bool = False ,
83+ sanitize : bool = False ,
84+ ) -> None : ...
85+ def encode (self , string : str ) -> str | bytes : ... # result depends on self.encoding
86+ def encodeStrict (self , string : str ) -> str | bytes : ... # result depends on self.encoding
87+ encoding : str | None
88+ @overload
89+ def serialize (self , treewalker , encoding : Literal ["" ] | None = None ) -> Generator [str ]: ...
90+ @overload
91+ def serialize (self , treewalker , encoding : str = ...) -> Generator [bytes ]: ...
92+ @overload
93+ def render (self , treewalker , encoding : Literal ["" ] | None = None ) -> str : ...
94+ @overload
95+ def render (self , treewalker , encoding : str = ...) -> bytes : ...
96+ def serializeError (self , data = "XXX ERROR MESSAGE NEEDED" ) -> None : ...
4197
4298class SerializeError (Exception ): ...
0 commit comments