mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 12:35:49 +08:00
[et-xmlfile] Add stubs (#14962)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
version = "2.0.*"
|
||||
upstream_repository = "https://foss.heptapod.net/openpyxl/et_xmlfile"
|
||||
@@ -0,0 +1,9 @@
|
||||
from typing import Final
|
||||
|
||||
from .xmlfile import xmlfile as xmlfile
|
||||
|
||||
__version__: Final[str]
|
||||
__author__: Final[str]
|
||||
__license__: Final[str]
|
||||
__author_email__: Final[str]
|
||||
__url__: Final[str]
|
||||
@@ -0,0 +1,170 @@
|
||||
import xml.etree.ElementTree as ET
|
||||
from _typeshed import Unused
|
||||
from collections.abc import Callable
|
||||
from typing import Any, Literal, overload
|
||||
|
||||
def current_global_nsmap() -> dict[str, str]: ...
|
||||
|
||||
class IncrementalTree(ET.ElementTree):
|
||||
def write( # type: ignore[override]
|
||||
self,
|
||||
file_or_filename: ET._FileWrite,
|
||||
encoding: str | None = None,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
method: Literal["xml", "html", "text"] | None = None, # does not accept 'c14n', unlike parent method
|
||||
*,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = False,
|
||||
minimal_ns_only: bool = False,
|
||||
) -> None: ...
|
||||
|
||||
def process_attribs(
|
||||
elem: ET.Element[Any],
|
||||
is_nsmap_scope_changed: bool | None,
|
||||
default_ns_attr_prefix: str | None,
|
||||
nsmap_scope: dict[str, str],
|
||||
global_nsmap: dict[str, str],
|
||||
new_namespace_prefixes: set[str],
|
||||
uri_to_prefix: dict[str, str],
|
||||
) -> tuple[list[tuple[str, str]], str | None, dict[str, str]]: ...
|
||||
def write_elem_start(
|
||||
write: Callable[..., None],
|
||||
elem: ET.Element[Any],
|
||||
nsmap_scope: dict[str, str],
|
||||
global_nsmap: dict[str, str],
|
||||
short_empty_elements: bool | None,
|
||||
is_html: bool | None,
|
||||
is_root: bool = False,
|
||||
uri_to_prefix: dict[str, str] | None = None,
|
||||
default_ns_attr_prefix: str | None = None,
|
||||
new_nsmap: dict[str, str] | None = None,
|
||||
**kwargs: Unused,
|
||||
) -> tuple[str | None, dict[str, str], str | None, dict[str, str] | None, bool]: ...
|
||||
@overload
|
||||
def tostring(
|
||||
element: ET.Element[Any],
|
||||
encoding: None = None,
|
||||
method: Literal["xml", "html", "text"] | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = False,
|
||||
minimal_ns_only: bool = False,
|
||||
tree_cls: type[ET.ElementTree] = ...,
|
||||
) -> bytes: ...
|
||||
@overload
|
||||
def tostring(
|
||||
element: ET.Element[Any],
|
||||
encoding: Literal["unicode"],
|
||||
method: Literal["xml", "html", "text"] | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = False,
|
||||
minimal_ns_only: bool = False,
|
||||
tree_cls: type[ET.ElementTree] = ...,
|
||||
) -> str: ...
|
||||
@overload
|
||||
def tostring(
|
||||
element: ET.Element[Any],
|
||||
encoding: str,
|
||||
method: Literal["xml", "html", "text"] | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = False,
|
||||
minimal_ns_only: bool = False,
|
||||
tree_cls: type[ET.ElementTree] = ...,
|
||||
) -> Any: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: ET.Element[Any],
|
||||
encoding: None = None,
|
||||
method: Literal["xml", "html", "text"] | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = False,
|
||||
minimal_ns_only: bool = False,
|
||||
tree_cls: type[ET.ElementTree] = ...,
|
||||
) -> list[bytes]: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: ET.Element[Any],
|
||||
encoding: Literal["unicode"],
|
||||
method: Literal["xml", "html", "text"] | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = False,
|
||||
minimal_ns_only: bool = False,
|
||||
tree_cls: type[ET.ElementTree] = ...,
|
||||
) -> list[str]: ...
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: ET.Element[Any],
|
||||
encoding: str,
|
||||
method: Literal["xml", "html", "text"] | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = False,
|
||||
minimal_ns_only: bool = False,
|
||||
tree_cls: type[ET.ElementTree] = ...,
|
||||
) -> list[Any]: ...
|
||||
@overload
|
||||
def compat_tostring(
|
||||
element: ET.Element[Any],
|
||||
encoding: None = None,
|
||||
method: Literal["xml", "html", "text"] | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = True,
|
||||
minimal_ns_only: bool = False,
|
||||
tree_cls: type[ET.ElementTree] = ...,
|
||||
) -> bytes: ...
|
||||
@overload
|
||||
def compat_tostring(
|
||||
element: ET.Element[Any],
|
||||
encoding: Literal["unicode"],
|
||||
method: Literal["xml", "html", "text"] | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = True,
|
||||
minimal_ns_only: bool = False,
|
||||
tree_cls: type[ET.ElementTree] = ...,
|
||||
) -> str: ...
|
||||
@overload
|
||||
def compat_tostring(
|
||||
element: ET.Element[Any],
|
||||
encoding: str,
|
||||
method: Literal["xml", "html", "text"] | None = None,
|
||||
*,
|
||||
xml_declaration: bool | None = None,
|
||||
default_namespace: str | None = None,
|
||||
short_empty_elements: bool = True,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
root_ns_only: bool = True,
|
||||
minimal_ns_only: bool = False,
|
||||
tree_cls: type[ET.ElementTree] = ...,
|
||||
) -> Any: ...
|
||||
@@ -0,0 +1,37 @@
|
||||
import types
|
||||
import xml.etree.ElementTree as ET
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Generator
|
||||
from contextlib import contextmanager
|
||||
from typing import Any
|
||||
|
||||
class LxmlSyntaxError(Exception): ...
|
||||
|
||||
class _IncrementalFileWriter:
|
||||
global_nsmap: dict[str, str]
|
||||
is_html: bool
|
||||
def __init__(self, output_file: ET._FileWrite) -> None: ...
|
||||
@contextmanager
|
||||
def element(
|
||||
self,
|
||||
tag: str | ET._ElementCallable,
|
||||
attrib: dict[str, str] | None = None,
|
||||
nsmap: dict[str, str] | None = None,
|
||||
**_extra: str,
|
||||
) -> Generator[None]: ...
|
||||
def write(self, arg: str | ET.Element[Any]) -> None: ...
|
||||
def __enter__(self) -> None: ...
|
||||
def __exit__(
|
||||
self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
class xmlfile:
|
||||
encoding: str
|
||||
writer_cm: Incomplete
|
||||
def __init__(
|
||||
self, output_file: ET._FileWrite, buffered: bool = False, encoding: str = "utf-8", close: bool = False
|
||||
) -> None: ...
|
||||
def __enter__(self) -> _IncrementalFileWriter: ...
|
||||
def __exit__(
|
||||
self, type: type[BaseException] | None, value: BaseException | None, traceback: types.TracebackType | None
|
||||
) -> None: ...
|
||||
Reference in New Issue
Block a user