|
1 | 1 | import sys
|
2 | 2 | import xml.dom
|
3 | 3 | from _typeshed import Incomplete, ReadableBuffer, SupportsRead, SupportsWrite
|
4 |
| -from typing import NoReturn, TypeVar |
| 4 | +from typing import NoReturn, TypeVar, overload |
5 | 5 | from typing_extensions import Literal, Self
|
6 | 6 | from xml.dom.minicompat import NodeList
|
7 | 7 | from xml.dom.xmlbuilder import DocumentLS, DOMImplementationLS
|
@@ -30,13 +30,69 @@ class Node(xml.dom.Node):
|
30 | 30 | def localName(self) -> str | None: ...
|
31 | 31 | def __bool__(self) -> Literal[True]: ...
|
32 | 32 | if sys.version_info >= (3, 9):
|
33 |
| - def toxml(self, encoding: str | None = None, standalone: bool | None = None) -> str: ... |
| 33 | + @overload |
| 34 | + def toxml(self, encoding: str, standalone: bool | None = None) -> bytes: ... |
| 35 | + @overload |
| 36 | + def toxml(self, encoding: None = None, standalone: bool | None = None) -> str: ... |
| 37 | + @overload |
34 | 38 | def toprettyxml(
|
35 |
| - self, indent: str = "\t", newl: str = "\n", encoding: str | None = None, standalone: bool | None = None |
| 39 | + self, |
| 40 | + indent: str = "\t", |
| 41 | + newl: str = "\n", |
| 42 | + # Handle any case where encoding is not provided or where it is passed with None |
| 43 | + encoding: None = None, |
| 44 | + standalone: bool | None = None, |
36 | 45 | ) -> str: ...
|
| 46 | + @overload |
| 47 | + def toprettyxml( |
| 48 | + self, |
| 49 | + indent: str, |
| 50 | + newl: str, |
| 51 | + # Handle cases where encoding is passed as str *positionally* |
| 52 | + encoding: str, |
| 53 | + standalone: bool | None = None, |
| 54 | + ) -> bytes: ... |
| 55 | + @overload |
| 56 | + def toprettyxml( |
| 57 | + self, |
| 58 | + indent: str = "\t", |
| 59 | + newl: str = "\n", |
| 60 | + # Handle all cases where encoding is passed as a keyword argument; because standalone |
| 61 | + # comes after, it will also have to be a keyword arg if encoding is |
| 62 | + *, |
| 63 | + encoding: str, |
| 64 | + standalone: bool | None = None, |
| 65 | + ) -> bytes: ... |
37 | 66 | else:
|
38 |
| - def toxml(self, encoding: str | None = None): ... |
39 |
| - def toprettyxml(self, indent: str = "\t", newl: str = "\n", encoding: str | None = None): ... |
| 67 | + @overload |
| 68 | + def toxml(self, encoding: str) -> bytes: ... |
| 69 | + @overload |
| 70 | + def toxml(self, encoding: None = None) -> str: ... |
| 71 | + @overload |
| 72 | + def toprettyxml( |
| 73 | + self, |
| 74 | + indent: str = "\t", |
| 75 | + newl: str = "\n", |
| 76 | + # Handle any case where encoding is not provided or where it is passed with None |
| 77 | + encoding: None = None, |
| 78 | + ) -> str: ... |
| 79 | + @overload |
| 80 | + def toprettyxml( |
| 81 | + self, |
| 82 | + indent: str, |
| 83 | + newl: str, |
| 84 | + # Handle cases where encoding is passed as str *positionally* |
| 85 | + encoding: str, |
| 86 | + ) -> bytes: ... |
| 87 | + @overload |
| 88 | + def toprettyxml( |
| 89 | + self, |
| 90 | + indent: str = "\t", |
| 91 | + newl: str = "\n", |
| 92 | + # Handle all cases where encoding is passed as a keyword argument |
| 93 | + *, |
| 94 | + encoding: str, |
| 95 | + ) -> bytes: ... |
40 | 96 |
|
41 | 97 | def hasChildNodes(self) -> bool: ...
|
42 | 98 | def insertBefore(self, newChild, refChild): ...
|
|
0 commit comments