Skip to content

Commit 89d4b1e

Browse files
committed
improve unparse
1 parent d9c76e1 commit 89d4b1e

File tree

2 files changed

+83
-17
lines changed

2 files changed

+83
-17
lines changed

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"stubs/tqdm",
9393
"stubs/vobject",
9494
"stubs/workalendar",
95+
"stubs/xmltodict",
9596
],
9697
"typeCheckingMode": "strict",
9798
// TODO: Complete incomplete stubs

stubs/xmltodict/xmltodict.pyi

Lines changed: 82 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,103 @@
1-
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
2-
from collections import OrderedDict
3-
from collections.abc import Mapping
1+
from _typeshed import Incomplete, ReadableBuffer, SupportsRead, SupportsWrite
2+
from collections.abc import Callable, Mapping
43
from types import GeneratorType
54
from typing import Any, overload
65

6+
__author__: str
7+
__version__: str
78
__license__: str
89

910
class ParsingInterrupted(Exception): ...
1011

12+
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
32+
def __init__(
33+
self,
34+
item_depth: int = 0,
35+
item_callback=...,
36+
xml_attribs: bool = True,
37+
attr_prefix: str = "@",
38+
cdata_key: str = "#text",
39+
force_cdata: bool = False,
40+
cdata_separator: str = "",
41+
postprocessor=None,
42+
dict_constructor=...,
43+
strip_whitespace: bool = True,
44+
namespace_separator: str = ":",
45+
namespaces=None,
46+
force_list=None,
47+
comment_key: str = "#comment",
48+
) -> 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+
1156
def parse(
1257
xml_input: str | ReadableBuffer | SupportsRead[bytes] | GeneratorType[ReadableBuffer, Any, Any],
13-
encoding: str | None = ...,
58+
encoding: str | None = None,
1459
expat: Any = ...,
15-
process_namespaces: bool = ...,
16-
namespace_separator: str = ...,
17-
disable_entities: bool = ...,
18-
process_comments: bool = ...,
60+
process_namespaces: bool = False,
61+
namespace_separator: str = ":",
62+
disable_entities: bool = True,
63+
process_comments: bool = False,
1964
**kwargs: Any,
20-
) -> OrderedDict[str, Any]: ...
65+
) -> dict[str, Any]: ...
2166
@overload
2267
def unparse(
2368
input_dict: Mapping[str, Any],
2469
output: SupportsWrite[bytes] | SupportsWrite[str],
25-
encoding: str = ...,
26-
full_document: bool = ...,
27-
short_empty_elements: bool = ...,
28-
**kwargs: Any,
70+
encoding: str = "utf-8",
71+
full_document: bool = True,
72+
short_empty_elements: bool = False,
73+
*,
74+
attr_prefix: str = "@",
75+
cdata_key: str = "#text",
76+
depth: int = 0,
77+
preprocessor: Callable[[str, Any], tuple[str, Any]] | None = None,
78+
pretty: bool = False,
79+
newl: str = "\n",
80+
indent: str = "\t",
81+
namespace_separator: str = ":",
82+
namespaces: dict[str, str] | None = None,
83+
expand_iter: str | None = None,
2984
) -> None: ...
3085
@overload
3186
def unparse(
3287
input_dict: Mapping[str, Any],
3388
output: None = ...,
34-
encoding: str = ...,
35-
full_document: bool = ...,
36-
short_empty_elements: bool = ...,
37-
**kwargs: Any,
89+
encoding: str = "utf-8",
90+
full_document: bool = True,
91+
short_empty_elements: bool = False,
92+
*,
93+
attr_prefix: str = "@",
94+
cdata_key: str = "#text",
95+
depth: int = 0,
96+
preprocessor: Callable[[str, Any], tuple[str, Any]] | None = None,
97+
pretty: bool = False,
98+
newl: str = "\n",
99+
indent: str = "\t",
100+
namespace_separator: str = ":",
101+
namespaces: dict[str, str] | None = None,
102+
expand_iter: str | None = None,
38103
) -> str: ...

0 commit comments

Comments
 (0)