Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 = "1.0.*"
version = "~= 1.0.1"
upstream_repository = "https://github.com/martinblech/xmltodict"
101 changes: 74 additions & 27 deletions stubs/xmltodict/xmltodict.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,60 @@
from _typeshed import Incomplete, ReadableBuffer, SupportsRead, SupportsWrite
from collections import OrderedDict
from collections.abc import Mapping
from types import GeneratorType
from typing import Any, Final, overload

__author__: Final[str]
__version__: Final[str]
__license__: Final[str]
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from collections.abc import Callable, Container, Generator, Mapping
from typing import Any, overload
from typing_extensions import TypeAlias

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:
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],
xml_input: str | ReadableBuffer | SupportsRead[bytes] | Generator[ReadableBuffer],
encoding: str | None = None,
expat: Any = ...,
process_namespaces: bool = False,
Expand All @@ -20,19 +63,19 @@ def parse(
process_comments: bool = False,
*,
item_depth: int = 0,
item_callback=...,
item_callback: Callable[[list[tuple[str, _AttrDict | None]], str | _AttrDict | None], bool] = ...,
xml_attribs: bool = True,
attr_prefix="@",
cdata_key="#text",
force_cdata: bool | Incomplete = False,
cdata_separator="",
postprocessor=None,
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=None,
force_list: bool | Incomplete = None,
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",
) -> OrderedDict[str, Any]: ...
) -> dict[str, Any]: ...
@overload
def unparse(
input_dict: Mapping[str, Any],
Expand All @@ -43,15 +86,17 @@ def unparse(
comment_key: str = "#comment",
*,
attr_prefix: str = "@",
cdata_key="#text",
cdata_key: str = "#text",
depth: int = 0,
preprocessor=None,
# preprocessor is called like (preprocessor(key, value) for key, value in input_dict.items()).
# It is expected to return its input, or a modification thereof
preprocessor: Callable[[str, Any], tuple[str, Any]] | None = None,
pretty: bool = False,
newl: str = "\n",
indent: str | int = "\t",
namespace_separator: str = ":",
namespaces=None,
expand_iter=None,
namespaces: Mapping[str, str] | None = None,
expand_iter: str | None = None,
) -> None: ...
@overload
def unparse(
Expand All @@ -63,13 +108,15 @@ def unparse(
comment_key: str = "#comment",
*,
attr_prefix: str = "@",
cdata_key="#text",
cdata_key: str = "#text",
depth: int = 0,
preprocessor=None,
# preprocessor is called like (preprocessor(key, value) for key, value in input_dict.items()).
# It is expected to return its input, or a modification thereof
preprocessor: Callable[[str, Any], tuple[str, Any]] | None = None,
pretty: bool = False,
newl: str = "\n",
indent: str | int = "\t",
namespace_separator: str = ":",
namespaces=None,
expand_iter=None,
namespaces: Mapping[str, str] | None = None,
expand_iter: str | None = None,
) -> str: ...
Loading