From 8ee4a0106d8c9e611758fdd94643c812cd05d093 Mon Sep 17 00:00:00 2001 From: Prometheus3375 Date: Tue, 14 Jun 2022 19:30:35 +0300 Subject: [PATCH 1/2] Change return type of XMLPullParser.read_events --- stdlib/xml/etree/ElementTree.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 85e1eaaa7742..3a54523f99bc 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -272,7 +272,7 @@ class XMLPullParser: def __init__(self, events: Sequence[str] | None = ..., *, _parser: XMLParser | None = ...) -> None: ... def feed(self, data: str | bytes) -> None: ... def close(self) -> None: ... - def read_events(self) -> Iterator[tuple[str, Element]]: ... + def read_events(self) -> Iterator[tuple[str, Any]]: ... def XML(text: str | bytes, parser: XMLParser | None = ...) -> Element: ... def XMLID(text: str | bytes, parser: XMLParser | None = ...) -> tuple[Element, dict[str, Element]]: ... From 2c9cefebe18abf0be415e21aa337c850fcb0bbb7 Mon Sep 17 00:00:00 2001 From: Prometheus3375 Date: Tue, 14 Jun 2022 21:07:18 +0300 Subject: [PATCH 2/2] Add comment about type of 2nd item Co-authored-by: Alex Waygood --- stdlib/xml/etree/ElementTree.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 3a54523f99bc..82cd735bd829 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -272,6 +272,8 @@ class XMLPullParser: def __init__(self, events: Sequence[str] | None = ..., *, _parser: XMLParser | None = ...) -> None: ... def feed(self, data: str | bytes) -> None: ... def close(self) -> None: ... + # Second element in the tuple could be `Element`, `tuple[str, str]` or `None`. + # Use `Any` to avoid false-positive errors. def read_events(self) -> Iterator[tuple[str, Any]]: ... def XML(text: str | bytes, parser: XMLParser | None = ...) -> Element: ...