Skip to content

Commit 5b121d5

Browse files
committed
complete all incomplete types
1 parent b9948ca commit 5b121d5

File tree

1 file changed

+62
-40
lines changed

1 file changed

+62
-40
lines changed

stubs/xmltodict/xmltodict.pyi

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,89 @@
1-
from _typeshed import Incomplete, ReadableBuffer, SupportsRead, SupportsWrite
1+
22
from collections.abc import Callable, Mapping
33
from types import GeneratorType
4-
from typing import Any, overload
4+
from typing import Any, TypeAlias, overload
5+
6+
from _typeshed import Incomplete, ReadableBuffer, SupportsRead, SupportsWrite
57

68
__author__: str
79
__version__: str
810
__license__: str
911

1012
class ParsingInterrupted(Exception): ...
1113

14+
# dict as attribute value may be a bug: https://github.com/martinblech/xmltodict/issues/163
15+
_AttrValue: TypeAlias = str|dict[str,str]
16+
_AttrDict: TypeAlias = dict[str, _AttrValue]
17+
1218
class _DictSAXHandler:
13-
path: Incomplete
14-
stack: Incomplete
15-
data: Incomplete
16-
item: Incomplete
17-
item_depth: Incomplete
18-
xml_attribs: Incomplete
19-
item_callback: Incomplete
20-
attr_prefix: Incomplete
21-
cdata_key: Incomplete
22-
force_cdata: Incomplete
23-
cdata_separator: Incomplete
24-
postprocessor: Incomplete
25-
dict_constructor: Incomplete
26-
strip_whitespace: Incomplete
27-
namespace_separator: Incomplete
28-
namespaces: Incomplete
29-
namespace_declarations: Incomplete
30-
force_list: Incomplete
31-
comment_key: Incomplete
19+
path: list[tuple[str, _AttrDict | None]] = []
20+
stack: list[tuple[_AttrDict | None, list[str]]] = []
21+
data: list[str] = []
22+
item: _AttrDict|None
23+
item_depth: int = 0
24+
xml_attribs: bool = True
25+
item_callback:Callable[[list[tuple[str, _AttrDict | None]], str | _AttrDict | None], bool]
26+
attr_prefix: str = "@"
27+
cdata_key: str = "#text"
28+
force_cdata: bool = False
29+
cdata_separator: str = ""
30+
postprocessor:Callable[[list[tuple[str, _AttrDict | None]], str, _AttrValue], tuple[str, _AttrValue]] | None=None
31+
dict_constructor: type[dict[str, str]]
32+
strip_whitespace: bool = True
33+
namespace_separator: str = ":"
34+
namespaces: dict[str, str] | None
35+
namespace_declarations: dict[str, str] = {}
36+
force_list:bool|tuple[str]|Callable[[tuple[str, _AttrDict | None], str, str], bool]|None=None
37+
comment_key: str = "#comment"
3238
def __init__(
3339
self,
3440
item_depth: int = 0,
35-
item_callback=...,
41+
item_callback:Callable[[list[tuple[str, _AttrDict | None]], str | _AttrDict | None], bool]=...,
3642
xml_attribs: bool = True,
3743
attr_prefix: str = "@",
3844
cdata_key: str = "#text",
3945
force_cdata: bool = False,
4046
cdata_separator: str = "",
41-
postprocessor=None,
42-
dict_constructor=...,
47+
postprocessor:Callable[[list[tuple[str, _AttrDict | None]], str, _AttrValue], tuple[str, _AttrValue]] | None=None,
48+
dict_constructor: type[dict[str, str]]=...,
4349
strip_whitespace: bool = True,
4450
namespace_separator: str = ":",
45-
namespaces=None,
46-
force_list=None,
51+
namespaces: dict[str, str] | None = None,
52+
force_list:bool|tuple[str]|Callable[[tuple[str, _AttrDict | None], str, str], bool]|None=None,
4753
comment_key: str = "#comment",
4854
) -> None: ...
49-
def startNamespaceDecl(self, prefix, uri) -> None: ...
50-
def startElement(self, full_name, attrs) -> None: ...
51-
def endElement(self, full_name) -> None: ...
52-
def characters(self, data) -> None: ...
53-
def comments(self, data) -> None: ...
54-
def push_data(self, item, key, data): ...
55+
def startNamespaceDecl(self, prefix: str, uri: str) -> None: ...
56+
def startElement(self, full_name:str, attrs: dict[str, str] | list[str]) -> None: ...
57+
def endElement(self, full_name: str) -> None: ...
58+
def characters(self, data: str) -> None: ...
59+
def comments(self, data: str) -> None: ...
60+
def push_data(self, item: _AttrDict|None, key: str, data: str) -> _AttrDict: ...
5561

5662
def parse(
57-
xml_input: str | ReadableBuffer | SupportsRead[bytes] | GeneratorType[ReadableBuffer, Any, Any],
63+
xml_input: str
64+
| ReadableBuffer
65+
| SupportsRead[bytes]
66+
| GeneratorType[ReadableBuffer, None, None],
5867
encoding: str | None = None,
59-
expat=...,
68+
expat:Any=...,
6069
process_namespaces: bool = False,
6170
namespace_separator: str = ":",
6271
disable_entities: bool = True,
6372
process_comments: bool = False,
64-
**kwargs: Any,
73+
*,
74+
item_depth: int = 0,
75+
item_callback:Callable[[list[tuple[str, _AttrDict | None]], str | _AttrDict | None], bool]=...,
76+
xml_attribs: bool = True,
77+
attr_prefix: str = "@",
78+
cdata_key: str = "#text",
79+
force_cdata: bool = False,
80+
cdata_separator: str = "",
81+
postprocessor:Callable[[list[tuple[str, _AttrDict | None]], str, _AttrValue], tuple[str, _AttrValue]] | None=None,
82+
dict_constructor: type[dict[str, str]]=...,
83+
strip_whitespace: bool = True,
84+
namespaces: dict[str, str] | None = None,
85+
force_list:bool|tuple[str]|Callable[[tuple[str, _AttrDict | None], str, str], bool]|None=None,
86+
comment_key: str = "#comment",
6587
) -> dict[str, Any]: ...
6688
@overload
6789
def unparse(
@@ -74,12 +96,12 @@ def unparse(
7496
attr_prefix: str = "@",
7597
cdata_key: str = "#text",
7698
depth: int = 0,
77-
preprocessor: Callable[[str, Incomplete], tuple[str, Incomplete]] | None = None,
99+
preprocessor: Callable[[str, Any], tuple[str, Any]] | None = None,
78100
pretty: bool = False,
79101
newl: str = "\n",
80102
indent: str = "\t",
81103
namespace_separator: str = ":",
82-
namespaces: dict[str, str] | None = None,
104+
namespaces: Mapping[str, str] | None = None,
83105
expand_iter: str | None = None,
84106
) -> None: ...
85107
@overload
@@ -93,11 +115,11 @@ def unparse(
93115
attr_prefix: str = "@",
94116
cdata_key: str = "#text",
95117
depth: int = 0,
96-
preprocessor: Callable[[str, Incomplete], tuple[str, Incomplete]] | None = None,
118+
preprocessor: Callable[[str, Any], tuple[str, Any]] | None = None,
97119
pretty: bool = False,
98120
newl: str = "\n",
99121
indent: str = "\t",
100122
namespace_separator: str = ":",
101-
namespaces: dict[str, str] | None = None,
123+
namespaces: Mapping[str, str] | None = None,
102124
expand_iter: str | None = None,
103-
) -> str: ...
125+
) -> str: ...

0 commit comments

Comments
 (0)