mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
* stdlib/xml/sax: Type annotations for commonly used methods. * stdlib/xml/sax: More annotations. It turns out SAX's definition of a "qname" is exactly the opposite of ElementTree's. With that understanding, let's annotate the Attributes*Impl classes too. * stdlib/xml/sax: I better understand what AttributesNSImpl is doing now. * Update third-party library stubs to agree with the new SAX annotations.
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
from collections.abc import Iterator, Mapping
|
|
from typing import Any
|
|
from typing_extensions import Self
|
|
from xml.sax import handler, xmlreader
|
|
|
|
def is_string(x: object) -> bool: ...
|
|
|
|
class Element:
|
|
children: list[Element]
|
|
is_root: bool
|
|
cdata: str
|
|
def __init__(self, name: str | None, attributes: Mapping[str, Any] | None) -> None: ...
|
|
def add_child(self, element: Element) -> None: ...
|
|
def add_cdata(self, cdata: str) -> None: ...
|
|
def get_attribute(self, key: str) -> Any | None: ...
|
|
def get_elements(self, name: str | None = ...) -> list[Element]: ...
|
|
def __getitem__(self, key: str) -> Any | None: ...
|
|
def __getattr__(self, key: str) -> Element: ...
|
|
def __hasattribute__(self, name: str) -> bool: ...
|
|
def __iter__(self) -> Iterator[Self]: ...
|
|
def __bool__(self) -> bool: ...
|
|
__nonzero__ = __bool__
|
|
def __eq__(self, val: object) -> bool: ...
|
|
def __dir__(self) -> list[str]: ...
|
|
def __len__(self) -> int: ...
|
|
def __contains__(self, key: str) -> bool: ...
|
|
|
|
class Handler(handler.ContentHandler):
|
|
root: Element
|
|
elements: list[Element]
|
|
def __init__(self) -> None: ...
|
|
def startElement(self, name: str, attributes: xmlreader.AttributesImpl) -> None: ...
|
|
def endElement(self, name: str) -> None: ...
|
|
def characters(self, cdata: str) -> None: ...
|
|
|
|
def parse(filename: str, **parser_features: bool) -> Element: ...
|
|
def is_url(string: str) -> bool: ...
|