From f96fe6abc0eaafc228276913030668c1058d6aad Mon Sep 17 00:00:00 2001 From: Shantanu Date: Sat, 1 Feb 2020 09:23:11 -0800 Subject: [PATCH] xml.etree.ElementTree: update for py38 (#3700) --- stdlib/2and3/xml/etree/ElementTree.pyi | 67 +++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/stdlib/2and3/xml/etree/ElementTree.pyi b/stdlib/2and3/xml/etree/ElementTree.pyi index 50e3a41b5..43c72394c 100644 --- a/stdlib/2and3/xml/etree/ElementTree.pyi +++ b/stdlib/2and3/xml/etree/ElementTree.pyi @@ -175,13 +175,78 @@ class ElementTree: def write_c14n(self, file: _file_or_filename) -> None: ... def register_namespace(prefix: _str_argument_type, uri: _str_argument_type) -> None: ... -if sys.version_info >= (3,): + +if sys.version_info >= (3, 8): + @overload + def tostring( + element: Element, + encoding: None = ..., + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> bytes: ... + @overload + def tostring( + element: Element, + encoding: Literal["unicode"], + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> str: ... + @overload + def tostring( + element: Element, + encoding: str, + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> Any: ... + + @overload + def tostringlist( + element: Element, + encoding: None = ..., + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> List[bytes]: ... + @overload + def tostringlist( + element: Element, + encoding: Literal["unicode"], + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> List[str]: ... + @overload + def tostringlist( + element: Element, + encoding: str, + method: Optional[str] = ..., + *, + xml_declaration: Optional[bool] = ..., + default_namespace: Optional[_str_argument_type] = ..., + short_empty_elements: bool = ..., + ) -> List[Any]: ... + +elif sys.version_info >= (3,): @overload def tostring(element: Element, encoding: None = ..., method: Optional[str] = ..., *, short_empty_elements: bool = ...) -> bytes: ... @overload def tostring(element: Element, encoding: Literal["unicode"], method: Optional[str] = ..., *, short_empty_elements: bool = ...) -> str: ... @overload def tostring(element: Element, encoding: str, method: Optional[str] = ..., *, short_empty_elements: bool = ...) -> Any: ... + @overload def tostringlist(element: Element, encoding: None = ..., method: Optional[str] = ..., *, short_empty_elements: bool = ...) -> List[bytes]: ... @overload