diff --git a/stdlib/xml/dom/minidom.pyi b/stdlib/xml/dom/minidom.pyi index b3d951752fca..47ec2dd18e4c 100644 --- a/stdlib/xml/dom/minidom.pyi +++ b/stdlib/xml/dom/minidom.pyi @@ -1,6 +1,6 @@ import sys import xml.dom -from _typeshed import Self, SupportsRead +from _typeshed import Incomplete, Self, SupportsRead, SupportsWrite from typing import Any from typing_extensions import Literal from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS @@ -25,11 +25,11 @@ class Node(xml.dom.Node): def localName(self) -> str | None: ... def __bool__(self) -> Literal[True]: ... if sys.version_info >= (3, 9): - def toxml(self, encoding: Any | None = ..., standalone: Any | None = ...): ... - def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Any | None = ..., standalone: Any | None = ...): ... + def toxml(self, encoding: str | None = ..., standalone: bool | None = ...): ... + def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: str | None = ..., standalone: bool | None = ...): ... else: - def toxml(self, encoding: Any | None = ...): ... - def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Any | None = ...): ... + def toxml(self, encoding: str | None = ...): ... + def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: str | None = ...): ... def hasChildNodes(self) -> bool: ... def insertBefore(self, newChild, refChild): ... @@ -70,7 +70,7 @@ class Attr(Node): value: str prefix: Any def __init__( - self, qName: str, namespaceURI: str | None = ..., localName: Any | None = ..., prefix: Any | None = ... + self, qName: str, namespaceURI: str | None = ..., localName: str | None = ..., prefix: Any | None = ... ) -> None: ... def unlink(self) -> None: ... @property @@ -87,31 +87,31 @@ class NamedNodeMap: def keys(self): ... def keysNS(self): ... def values(self): ... - def get(self, name, value: Any | None = ...): ... + def get(self, name: str, value: Any | None = ...): ... def __len__(self) -> int: ... def __eq__(self, other: object) -> bool: ... - def __ge__(self, other: Any) -> bool: ... - def __gt__(self, other: Any) -> bool: ... - def __le__(self, other: Any) -> bool: ... - def __lt__(self, other: Any) -> bool: ... - def __getitem__(self, attname_or_tuple): ... - def __setitem__(self, attname, value) -> None: ... - def getNamedItem(self, name): ... - def getNamedItemNS(self, namespaceURI: str, localName): ... - def removeNamedItem(self, name): ... - def removeNamedItemNS(self, namespaceURI: str, localName): ... - def setNamedItem(self, node): ... - def setNamedItemNS(self, node): ... - def __delitem__(self, attname_or_tuple) -> None: ... + def __ge__(self, other: NamedNodeMap) -> bool: ... + def __gt__(self, other: NamedNodeMap) -> bool: ... + def __le__(self, other: NamedNodeMap) -> bool: ... + def __lt__(self, other: NamedNodeMap) -> bool: ... + def __getitem__(self, attname_or_tuple: tuple[str, str | None] | str): ... + def __setitem__(self, attname: str, value: Attr | str) -> None: ... + def getNamedItem(self, name: str) -> Attr | None: ... + def getNamedItemNS(self, namespaceURI: str, localName: str | None) -> Attr | None: ... + def removeNamedItem(self, name: str) -> Attr: ... + def removeNamedItemNS(self, namespaceURI: str, localName: str | None): ... + def setNamedItem(self, node: Attr) -> Attr: ... + def setNamedItemNS(self, node: Attr) -> Attr: ... + def __delitem__(self, attname_or_tuple: tuple[str, str | None] | str) -> None: ... @property def length(self) -> int: ... AttributeList = NamedNodeMap class TypeInfo: - namespace: Any - name: Any - def __init__(self, namespace, name) -> None: ... + namespace: Incomplete | None + name: str + def __init__(self, namespace: Incomplete | None, name: str) -> None: ... class Element(Node): nodeType: int @@ -144,7 +144,7 @@ class Element(Node): def hasAttributeNS(self, namespaceURI: str, localName) -> bool: ... def getElementsByTagName(self, name: str): ... def getElementsByTagNameNS(self, namespaceURI: str, localName): ... - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... + def writexml(self, writer: SupportsWrite[str], indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... def hasAttributes(self) -> bool: ... def setIdAttribute(self, name) -> None: ... def setIdAttributeNS(self, namespaceURI: str, localName) -> None: ... @@ -171,7 +171,7 @@ class ProcessingInstruction(Childless, Node): def __init__(self, target, data) -> None: ... nodeValue: Any nodeName: Any - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... + def writexml(self, writer: SupportsWrite[str], indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... class CharacterData(Childless, Node): ownerDocument: Any @@ -194,7 +194,7 @@ class Text(CharacterData): attributes: Any data: Any def splitText(self, offset): ... - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... + def writexml(self, writer: SupportsWrite[str], indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... def replaceWholeText(self, content): ... @property def isWhitespaceInElementContent(self) -> bool: ... @@ -205,12 +205,12 @@ class Comment(CharacterData): nodeType: int nodeName: str def __init__(self, data) -> None: ... - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... + def writexml(self, writer: SupportsWrite[str], indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... class CDATASection(Text): nodeType: int nodeName: str - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... + def writexml(self, writer: SupportsWrite[str], indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... class ReadOnlySequentialNamedNodeMap: def __init__(self, seq=...) -> None: ... @@ -240,7 +240,7 @@ class DocumentType(Identified, Childless, Node): nodeName: Any def __init__(self, qualifiedName: str) -> None: ... def cloneNode(self, deep): ... - def writexml(self, writer, indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... + def writexml(self, writer: SupportsWrite[str], indent: str = ..., addindent: str = ..., newl: str = ...) -> None: ... class Entity(Identified, Node): attributes: Any @@ -290,13 +290,13 @@ class Document(Node, DocumentLS): previousSibling: Any nextSibling: Any actualEncoding: Any - encoding: Any - standalone: Any + encoding: str | None + standalone: bool | None version: Any strictErrorChecking: bool errorHandler: Any documentURI: Any - doctype: Any + doctype: DocumentType | None childNodes: Any def __init__(self) -> None: ... def appendChild(self, node): ... @@ -304,11 +304,11 @@ class Document(Node, DocumentLS): def removeChild(self, oldChild): ... def unlink(self) -> None: ... def cloneNode(self, deep): ... - def createDocumentFragment(self): ... - def createElement(self, tagName: str): ... - def createTextNode(self, data): ... - def createCDATASection(self, data): ... - def createComment(self, data): ... + def createDocumentFragment(self) -> DocumentFragment: ... + def createElement(self, tagName: str) -> Element: ... + def createTextNode(self, data: str) -> Text: ... + def createCDATASection(self, data: str) -> CDATASection: ... + def createComment(self, data: str) -> Comment: ... def createProcessingInstruction(self, target, data): ... def createAttribute(self, qName) -> Attr: ... def createElementNS(self, namespaceURI: str, qualifiedName: str): ... @@ -316,21 +316,21 @@ class Document(Node, DocumentLS): def getElementById(self, id): ... def getElementsByTagName(self, name: str): ... def getElementsByTagNameNS(self, namespaceURI: str, localName): ... - def isSupported(self, feature, version): ... + def isSupported(self, feature: str, version: str | None) -> bool: ... def importNode(self, node, deep): ... if sys.version_info >= (3, 9): def writexml( self, - writer, + writer: SupportsWrite[str], indent: str = ..., addindent: str = ..., newl: str = ..., - encoding: Any | None = ..., - standalone: Any | None = ..., + encoding: str | None = ..., + standalone: bool | None = ..., ) -> None: ... else: def writexml( - self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Any | None = ... + self, writer: SupportsWrite[str], indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Any | None = ... ) -> None: ... def renameNode(self, n, namespaceURI: str, name): ... diff --git a/stdlib/xml/sax/handler.pyi b/stdlib/xml/sax/handler.pyi index abf124f836cd..7aeb41405e04 100644 --- a/stdlib/xml/sax/handler.pyi +++ b/stdlib/xml/sax/handler.pyi @@ -1,11 +1,12 @@ import sys +from typing import NoReturn version: str class ErrorHandler: - def error(self, exception): ... - def fatalError(self, exception): ... - def warning(self, exception): ... + def error(self, exception: BaseException) -> NoReturn: ... + def fatalError(self, exception: BaseException) -> NoReturn: ... + def warning(self, exception: BaseException) -> None: ... class ContentHandler: def __init__(self) -> None: ...