1
1
import sys
2
2
from _collections_abc import dict_keys
3
- from _typeshed import FileDescriptor , StrOrBytesPath , SupportsRead , SupportsWrite
3
+ from _typeshed import FileDescriptor , ReadableBuffer , StrOrBytesPath , SupportsRead , SupportsWrite
4
4
from collections .abc import Callable , Generator , ItemsView , Iterable , Iterator , Mapping , Sequence
5
5
from typing import Any , TypeVar , overload
6
6
from typing_extensions import Literal , SupportsIndex , TypeAlias , TypeGuard
@@ -54,7 +54,7 @@ def iselement(element: object) -> TypeGuard[Element]: ...
54
54
if sys .version_info >= (3 , 8 ):
55
55
@overload
56
56
def canonicalize (
57
- xml_data : str | bytes | None = ...,
57
+ xml_data : str | ReadableBuffer | None = ...,
58
58
* ,
59
59
out : None = ...,
60
60
from_file : _FileRead | None = ...,
@@ -68,7 +68,7 @@ if sys.version_info >= (3, 8):
68
68
) -> str : ...
69
69
@overload
70
70
def canonicalize (
71
- xml_data : str | bytes | None = ...,
71
+ xml_data : str | ReadableBuffer | None = ...,
72
72
* ,
73
73
out : SupportsWrite [str ],
74
74
from_file : _FileRead | None = ...,
@@ -270,19 +270,19 @@ def iterparse(
270
270
271
271
class XMLPullParser :
272
272
def __init__ (self , events : Sequence [str ] | None = ..., * , _parser : XMLParser | None = ...) -> None : ...
273
- def feed (self , data : str | bytes ) -> None : ...
273
+ def feed (self , data : str | ReadableBuffer ) -> None : ...
274
274
def close (self ) -> None : ...
275
275
# Second element in the tuple could be `Element`, `tuple[str, str]` or `None`.
276
276
# Use `Any` to avoid false-positive errors.
277
277
def read_events (self ) -> Iterator [tuple [str , Any ]]: ...
278
278
279
- def XML (text : str | bytes , parser : XMLParser | None = ...) -> Element : ...
280
- def XMLID (text : str | bytes , parser : XMLParser | None = ...) -> tuple [Element , dict [str , Element ]]: ...
279
+ def XML (text : str | ReadableBuffer , parser : XMLParser | None = ...) -> Element : ...
280
+ def XMLID (text : str | ReadableBuffer , parser : XMLParser | None = ...) -> tuple [Element , dict [str , Element ]]: ...
281
281
282
282
# This is aliased to XML in the source.
283
283
fromstring = XML
284
284
285
- def fromstringlist (sequence : Sequence [str | bytes ], parser : XMLParser | None = ...) -> Element : ...
285
+ def fromstringlist (sequence : Sequence [str | ReadableBuffer ], parser : XMLParser | None = ...) -> Element : ...
286
286
287
287
# This type is both not precise enough and too precise. The TreeBuilder
288
288
# requires the elementfactory to accept tag and attrs in its args and produce
@@ -313,9 +313,11 @@ class TreeBuilder:
313
313
def __init__ (self , element_factory : _ElementFactory | None = ...) -> None : ...
314
314
315
315
def close (self ) -> Element : ...
316
- def data (self , __data : str | bytes ) -> None : ...
317
- def start (self , __tag : str | bytes , __attrs : dict [str | bytes , str | bytes ]) -> Element : ...
318
- def end (self , __tag : str | bytes ) -> Element : ...
316
+ def data (self , __data : str ) -> None : ...
317
+ # tag and attrs are passed to the element_factory, so they could be anything
318
+ # depending on what the particular factory supports.
319
+ def start (self , __tag : Any , __attrs : dict [Any , Any ]) -> Element : ...
320
+ def end (self , __tag : str ) -> Element : ...
319
321
if sys .version_info >= (3 , 8 ):
320
322
# These two methods have pos-only parameters in the C implementation
321
323
def comment (self , __text : str | None ) -> Element : ...
@@ -355,4 +357,4 @@ class XMLParser:
355
357
def doctype (self , __name : str , __pubid : str , __system : str ) -> None : ...
356
358
357
359
def close (self ) -> Any : ...
358
- def feed (self , __data : str | bytes ) -> None : ...
360
+ def feed (self , __data : str | ReadableBuffer ) -> None : ...
0 commit comments