Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/xmltodict/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "0.15.*"
version = "1.0.*"
upstream_repository = "https://github.com/martinblech/xmltodict"
127 changes: 106 additions & 21 deletions stubs/xmltodict/xmltodict.pyi
Original file line number Diff line number Diff line change
@@ -1,38 +1,123 @@
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from collections import OrderedDict
from collections.abc import Mapping
from collections.abc import Callable, Container, Mapping
from types import GeneratorType
from typing import Any, overload
from typing import Any, Final, overload
from typing_extensions import TypeAlias

__license__: str
__author__: Final[str]
__version__: Final[str]
__license__: Final[str]

class ParsingInterrupted(Exception): ...

# dict as attribute value is exclusive to xmlns: https://github.com/bigpick/xmltodict/commit/22541b4874365cb8d2397f23087a866b3081fd9c
_AttrValue: TypeAlias = str | dict[str, str]
_AttrDict: TypeAlias = dict[str, _AttrValue]

class _DictSAXHandler:
Comment thread
tapple-cisco marked this conversation as resolved.
path: list[tuple[str, _AttrDict | None]]
stack: list[tuple[_AttrDict | None, list[str]]]
data: list[str]
item: _AttrDict | None
item_depth: int
xml_attribs: bool
item_callback: Callable[[list[tuple[str, _AttrDict | None]], str | _AttrDict | None], bool]
attr_prefix: str
cdata_key: str
force_cdata: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool]
cdata_separator: str
postprocessor: Callable[[list[tuple[str, _AttrDict | None]], str, _AttrValue], tuple[str, _AttrValue]] | None
dict_constructor: type
strip_whitespace: bool
namespace_separator: str
namespaces: dict[str, str] | None
namespace_declarations: dict[str, str]
force_list: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] | None
comment_key: str
def __init__(
self,
item_depth: int = 0,
item_callback: Callable[[list[tuple[str, _AttrDict | None]], str | _AttrDict | None], bool] = ...,
xml_attribs: bool = True,
attr_prefix: str = "@",
cdata_key: str = "#text",
force_cdata: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] = False,
cdata_separator: str = "",
postprocessor: Callable[[list[tuple[str, _AttrDict | None]], str, _AttrValue], tuple[str, _AttrValue]] | None = None,
dict_constructor: type = ...,
strip_whitespace: bool = True,
namespace_separator: str = ":",
namespaces: dict[str, str] | None = None,
force_list: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] | None = None,
comment_key: str = "#comment",
) -> None: ...
def startNamespaceDecl(self, prefix: str, uri: str) -> None: ...
def startElement(self, full_name: str, attrs: dict[str, str] | list[str]) -> None: ...
def endElement(self, full_name: str) -> None: ...
def characters(self, data: str) -> None: ...
def comments(self, data: str) -> None: ...
def push_data(self, item: _AttrDict | None, key: str, data: str) -> _AttrDict: ...

def parse(
xml_input: str | ReadableBuffer | SupportsRead[bytes] | GeneratorType[ReadableBuffer, Any, Any],
encoding: str | None = ...,
xml_input: str | ReadableBuffer | SupportsRead[bytes] | GeneratorType[ReadableBuffer, None, None],
Comment thread
tapple-cisco marked this conversation as resolved.
Outdated
encoding: str | None = None,
expat: Any = ...,
process_namespaces: bool = ...,
namespace_separator: str = ...,
disable_entities: bool = ...,
process_comments: bool = ...,
**kwargs: Any,
) -> OrderedDict[str, Any]: ...
process_namespaces: bool = False,
namespace_separator: str = ":",
disable_entities: bool = True,
process_comments: bool = False,
*,
item_depth: int = 0,
item_callback: Callable[[list[tuple[str, _AttrDict | None]], str | _AttrDict | None], bool] = ...,
xml_attribs: bool = True,
attr_prefix: str = "@",
cdata_key: str = "#text",
force_cdata: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] = False,
cdata_separator: str = "",
postprocessor: Callable[[list[tuple[str, _AttrDict | None]], str, _AttrValue], tuple[str, _AttrValue]] | None = None,
dict_constructor: type = ...,
strip_whitespace: bool = True,
namespaces: dict[str, str] | None = None,
force_list: bool | Container[str] | Callable[[tuple[str, _AttrDict | None], str, str], bool] | None = None,
comment_key: str = "#comment",
) -> dict[str, Any]: ...
@overload
def unparse(
input_dict: Mapping[str, Any],
output: SupportsWrite[bytes] | SupportsWrite[str],
encoding: str = ...,
full_document: bool = ...,
short_empty_elements: bool = ...,
**kwargs: Any,
encoding: str = "utf-8",
full_document: bool = True,
short_empty_elements: bool = False,
comment_key: str = "#comment",
*,
attr_prefix: str = "@",
cdata_key: str = "#text",
depth: int = 0,
preprocessor: Callable[[str, Any], tuple[str, Any]] | None = None,
Comment thread
tapple-cisco marked this conversation as resolved.
pretty: bool = False,
newl: str = "\n",
indent: str | int = "\t",
namespace_separator: str = ":",
namespaces: Mapping[str, str] | None = None,
expand_iter: str | None = None,
) -> None: ...
@overload
def unparse(
input_dict: Mapping[str, Any],
output: None = ...,
encoding: str = ...,
full_document: bool = ...,
short_empty_elements: bool = ...,
**kwargs: Any,
output: None = None,
encoding: str = "utf-8",
full_document: bool = True,
short_empty_elements: bool = False,
comment_key: str = "#comment",
*,
attr_prefix: str = "@",
cdata_key: str = "#text",
depth: int = 0,
preprocessor: Callable[[str, Any], tuple[str, Any]] | None = None,
Comment thread
tapple-cisco marked this conversation as resolved.
pretty: bool = False,
newl: str = "\n",
indent: str | int = "\t",
namespace_separator: str = ":",
namespaces: Mapping[str, str] | None = None,
expand_iter: str | None = None,
) -> str: ...
Loading