Skip to content

Complete type stubs for xml.dom.minidom (#6886) #10879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 4 additions & 2 deletions stdlib/xml/dom/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Protocol

from .domreg import getDOMImplementation as getDOMImplementation, registerDOMImplementation as registerDOMImplementation

Expand Down Expand Up @@ -56,12 +56,14 @@ class NamespaceErr(DOMException): ...
class InvalidAccessErr(DOMException): ...
class ValidationErr(DOMException): ...

class UserDataHandler:
class UserDataHandler(Protocol):
NODE_CLONED: int
NODE_IMPORTED: int
NODE_DELETED: int
NODE_RENAMED: int

def handle(self, operation: int, key: str, data: object, src: Node, dst: Node) -> None: ...

XML_NAMESPACE: str
XMLNS_NAMESPACE: str
XHTML_NAMESPACE: str
Expand Down
8 changes: 4 additions & 4 deletions stdlib/xml/dom/minicompat.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from collections.abc import Iterable
from typing import Any, TypeVar
from collections.abc import Iterable, Sequence
from typing import Any, Protocol, TypeVar
from typing_extensions import Literal

__all__ = ["NodeList", "EmptyNodeList", "StringTypes", "defproperty"]

_T = TypeVar("_T")
_T = TypeVar("_T", covariant=True)

StringTypes: tuple[type[str]]

class NodeList(list[_T]):
class NodeList(Sequence[_T], Protocol):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right. At runtime NodeList inherits from list and it is indeed a list and its append method is used elsewhere in the code. Why was it changed?

@property
def length(self) -> int: ...
def item(self, index: int) -> _T | None: ...
Expand Down
Loading