Skip to content

Commit 3fc2f27

Browse files
authored
Add missing types in xml.dom.minidom (#9731)
1 parent d92332d commit 3fc2f27

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

stdlib/xml/dom/minidom.pyi

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import sys
22
import xml.dom
33
from _typeshed import Incomplete, ReadableBuffer, SupportsRead, SupportsWrite
4+
from typing import NoReturn, TypeVar
45
from typing_extensions import Literal, Self
6+
from xml.dom.minicompat import NodeList
57
from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS
68
from xml.sax.xmlreader import XMLReader
79

10+
_N = TypeVar("_N", bound=Node)
11+
812
def parse(file: str | SupportsRead[ReadableBuffer | str], parser: XMLReader | None = None, bufsize: int | None = None): ...
913
def parseString(string: str | ReadableBuffer, parser: XMLReader | None = None): ...
1014
def getDOMImplementation(features=None) -> DOMImplementation | None: ...
@@ -34,7 +38,7 @@ class Node(xml.dom.Node):
3438

3539
def hasChildNodes(self) -> bool: ...
3640
def insertBefore(self, newChild, refChild): ...
37-
def appendChild(self, node): ...
41+
def appendChild(self, node: _N) -> _N: ...
3842
def replaceChild(self, newChild, oldChild): ...
3943
def removeChild(self, oldChild): ...
4044
def normalize(self) -> None: ...
@@ -143,7 +147,7 @@ class Element(Node):
143147
removeAttributeNodeNS: Incomplete
144148
def hasAttribute(self, name: str) -> bool: ...
145149
def hasAttributeNS(self, namespaceURI: str, localName) -> bool: ...
146-
def getElementsByTagName(self, name: str): ...
150+
def getElementsByTagName(self, name: str) -> NodeList[Node]: ...
147151
def getElementsByTagNameNS(self, namespaceURI: str, localName): ...
148152
def writexml(self, writer: SupportsWrite[str], indent: str = "", addindent: str = "", newl: str = "") -> None: ...
149153
def hasAttributes(self) -> bool: ...
@@ -158,12 +162,12 @@ class Childless:
158162
childNodes: Incomplete
159163
firstChild: Incomplete
160164
lastChild: Incomplete
161-
def appendChild(self, node) -> None: ...
165+
def appendChild(self, node) -> NoReturn: ...
162166
def hasChildNodes(self) -> bool: ...
163-
def insertBefore(self, newChild, refChild) -> None: ...
164-
def removeChild(self, oldChild) -> None: ...
167+
def insertBefore(self, newChild, refChild) -> NoReturn: ...
168+
def removeChild(self, oldChild) -> NoReturn: ...
165169
def normalize(self) -> None: ...
166-
def replaceChild(self, newChild, oldChild) -> None: ...
170+
def replaceChild(self, newChild, oldChild) -> NoReturn: ...
167171

168172
class ProcessingInstruction(Childless, Node):
169173
nodeType: int
@@ -254,10 +258,10 @@ class Entity(Identified, Node):
254258
notationName: Incomplete
255259
childNodes: Incomplete
256260
def __init__(self, name, publicId, systemId, notation) -> None: ...
257-
def appendChild(self, newChild) -> None: ...
258-
def insertBefore(self, newChild, refChild) -> None: ...
259-
def removeChild(self, oldChild) -> None: ...
260-
def replaceChild(self, newChild, oldChild) -> None: ...
261+
def appendChild(self, newChild) -> NoReturn: ...
262+
def insertBefore(self, newChild, refChild) -> NoReturn: ...
263+
def removeChild(self, oldChild) -> NoReturn: ...
264+
def replaceChild(self, newChild, oldChild) -> NoReturn: ...
261265

262266
class Notation(Identified, Childless, Node):
263267
nodeType: int
@@ -300,7 +304,7 @@ class Document(Node, DocumentLS):
300304
doctype: DocumentType | None
301305
childNodes: Incomplete
302306
def __init__(self) -> None: ...
303-
def appendChild(self, node): ...
307+
def appendChild(self, node: _N) -> _N: ...
304308
documentElement: Incomplete
305309
def removeChild(self, oldChild): ...
306310
def unlink(self) -> None: ...
@@ -315,7 +319,7 @@ class Document(Node, DocumentLS):
315319
def createElementNS(self, namespaceURI: str, qualifiedName: str): ...
316320
def createAttributeNS(self, namespaceURI: str, qualifiedName: str) -> Attr: ...
317321
def getElementById(self, id): ...
318-
def getElementsByTagName(self, name: str): ...
322+
def getElementsByTagName(self, name: str) -> NodeList[Node]: ...
319323
def getElementsByTagNameNS(self, namespaceURI: str, localName): ...
320324
def isSupported(self, feature: str, version: str | None) -> bool: ...
321325
def importNode(self, node, deep): ...

0 commit comments

Comments
 (0)