clean python 3 specific stuff from stdlib/@python2 stubs (#5451)

This commit is contained in:
Akuli
2021-05-15 01:19:05 +03:00
committed by GitHub
parent f94d838814
commit 5ec4f06263
121 changed files with 1024 additions and 4801 deletions

View File

@@ -17,14 +17,8 @@ class Node(xml.dom.Node):
nextSibling: Any
previousSibling: Any
prefix: Any
if sys.version_info >= (3, 9):
def toxml(self, encoding: Optional[Any] = ..., standalone: Optional[Any] = ...): ...
def toprettyxml(
self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ..., standalone: Optional[Any] = ...
): ...
else:
def toxml(self, encoding: Optional[Any] = ...): ...
def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ...): ...
def toxml(self, encoding: Optional[Any] = ...): ...
def toprettyxml(self, indent: str = ..., newl: str = ..., encoding: Optional[Any] = ...): ...
def hasChildNodes(self) -> bool: ...
def insertBefore(self, newChild, refChild): ...
def appendChild(self, node): ...
@@ -295,18 +289,7 @@ class Document(Node, DocumentLS):
def getElementsByTagNameNS(self, namespaceURI: str, localName): ...
def isSupported(self, feature, version): ...
def importNode(self, node, deep): ...
if sys.version_info >= (3, 9):
def writexml(
self,
writer,
indent: str = ...,
addindent: str = ...,
newl: str = ...,
encoding: Optional[Any] = ...,
standalone: Optional[Any] = ...,
) -> None: ...
else:
def writexml(
self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Optional[Any] = ...
) -> None: ...
def writexml(
self, writer, indent: str = ..., addindent: str = ..., newl: str = ..., encoding: Optional[Any] = ...
) -> None: ...
def renameNode(self, n, namespaceURI: str, name): ...

View File

@@ -13,13 +13,4 @@ def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[
# TODO: loader is of type default_loader ie it takes a callable that has the
# same signature as default_loader. But default_loader has a keyword argument
# Which can't be represented using Callable...
if sys.version_info >= (3, 9):
def include(
elem: Element,
loader: Optional[Callable[..., Union[str, Element]]] = ...,
base_url: Optional[str] = ...,
max_depth: Optional[int] = ...,
) -> None: ...
else:
def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ...
def include(elem: Element, loader: Optional[Callable[..., Union[str, Element]]] = ...) -> None: ...

View File

@@ -47,47 +47,13 @@ _parser_input_type = Union[bytes, Text]
_str_argument_type = Union[str, Text]
# Type for return values from individual tag/attr/text values
if sys.version_info >= (3,):
# note: in python3, everything comes out as str, yay:
_str_result_type = str
else:
# in python2, if the tag/attribute/text wasn't decode-able as ascii, it
# comes out as a unicode string; otherwise it comes out as str. (see
# _fixtext function in the source). Client code knows best:
_str_result_type = Any
# in python2, if the tag/attribute/text wasn't decode-able as ascii, it
# comes out as a unicode string; otherwise it comes out as str. (see
# _fixtext function in the source). Client code knows best:
_str_result_type = Any
_file_or_filename = Union[AnyPath, FileDescriptor, IO[Any]]
if sys.version_info >= (3, 8):
@overload
def canonicalize(
xml_data: Optional[_parser_input_type] = ...,
*,
out: None = ...,
from_file: Optional[_file_or_filename] = ...,
with_comments: bool = ...,
strip_text: bool = ...,
rewrite_prefixes: bool = ...,
qname_aware_tags: Optional[Iterable[str]] = ...,
qname_aware_attrs: Optional[Iterable[str]] = ...,
exclude_attrs: Optional[Iterable[str]] = ...,
exclude_tags: Optional[Iterable[str]] = ...,
) -> str: ...
@overload
def canonicalize(
xml_data: Optional[_parser_input_type] = ...,
*,
out: SupportsWrite[str],
from_file: Optional[_file_or_filename] = ...,
with_comments: bool = ...,
strip_text: bool = ...,
rewrite_prefixes: bool = ...,
qname_aware_tags: Optional[Iterable[str]] = ...,
qname_aware_attrs: Optional[Iterable[str]] = ...,
exclude_attrs: Optional[Iterable[str]] = ...,
exclude_tags: Optional[Iterable[str]] = ...,
) -> None: ...
class Element(MutableSequence[Element]):
tag: _str_result_type
attrib: Dict[_str_result_type, _str_result_type]
@@ -123,10 +89,7 @@ class Element(MutableSequence[Element]):
def get(self, key: _str_argument_type, default: None = ...) -> Optional[_str_result_type]: ...
@overload
def get(self, key: _str_argument_type, default: _T) -> Union[_str_result_type, _T]: ...
if sys.version_info >= (3, 2):
def insert(self, __index: int, __subelement: Element) -> None: ...
else:
def insert(self, __index: int, __element: Element) -> None: ...
def insert(self, __index: int, __element: Element) -> None: ...
def items(self) -> ItemsView[_str_result_type, _str_result_type]: ...
def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ...
def iterfind(
@@ -147,9 +110,8 @@ class Element(MutableSequence[Element]):
def __setitem__(self, i: int, o: Element) -> None: ...
@overload
def __setitem__(self, s: slice, o: Iterable[Element]) -> None: ...
if sys.version_info < (3, 9):
def getchildren(self) -> List[Element]: ...
def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ...
def getchildren(self) -> List[Element]: ...
def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ...
def SubElement(
parent: Element,
@@ -171,8 +133,7 @@ class ElementTree:
def getroot(self) -> Element: ...
def parse(self, source: _file_or_filename, parser: Optional[XMLParser] = ...) -> Element: ...
def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ...
if sys.version_info < (3, 9):
def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ...
def getiterator(self, tag: Optional[_str_argument_type] = ...) -> List[Element]: ...
def find(
self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
) -> Optional[Element]: ...
@@ -193,137 +154,24 @@ class ElementTree:
def iterfind(
self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
) -> Generator[Element, None, None]: ...
if sys.version_info >= (3, 4):
def write(
self,
file_or_filename: _file_or_filename,
encoding: Optional[str] = ...,
xml_declaration: Optional[bool] = ...,
default_namespace: Optional[_str_argument_type] = ...,
method: Optional[str] = ...,
*,
short_empty_elements: bool = ...,
) -> None: ...
else:
def write(
self,
file_or_filename: _file_or_filename,
encoding: Optional[str] = ...,
xml_declaration: Optional[bool] = ...,
default_namespace: Optional[_str_argument_type] = ...,
method: Optional[str] = ...,
) -> None: ...
def write(
self,
file_or_filename: _file_or_filename,
encoding: Optional[str] = ...,
xml_declaration: Optional[bool] = ...,
default_namespace: Optional[_str_argument_type] = ...,
method: Optional[str] = ...,
) -> None: ...
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, 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
def tostringlist(
element: Element, encoding: Literal["unicode"], method: Optional[str] = ..., *, short_empty_elements: bool = ...
) -> List[str]: ...
@overload
def tostringlist(
element: Element, encoding: str, method: Optional[str] = ..., *, short_empty_elements: bool = ...
) -> List[Any]: ...
else:
def tostring(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> bytes: ...
def tostringlist(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> List[bytes]: ...
def tostring(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> bytes: ...
def tostringlist(element: Element, encoding: Optional[str] = ..., method: Optional[str] = ...) -> List[bytes]: ...
def dump(elem: Element) -> None: ...
if sys.version_info >= (3, 9):
def indent(tree: Union[Element, ElementTree], space: str = ..., level: int = ...) -> None: ...
def parse(source: _file_or_filename, parser: Optional[XMLParser] = ...) -> ElementTree: ...
def iterparse(
source: _file_or_filename, events: Optional[Sequence[str]] = ..., parser: Optional[XMLParser] = ...
) -> Iterator[Tuple[str, Any]]: ...
if sys.version_info >= (3, 4):
class XMLPullParser:
def __init__(self, events: Optional[Sequence[str]] = ..., *, _parser: Optional[XMLParser] = ...) -> None: ...
def feed(self, data: bytes) -> None: ...
def close(self) -> None: ...
def read_events(self) -> Iterator[Tuple[str, Element]]: ...
def XML(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Element: ...
def XMLID(text: _parser_input_type, parser: Optional[XMLParser] = ...) -> Tuple[Element, Dict[_str_result_type, Element]]: ...
@@ -350,31 +198,13 @@ class TreeBuilder:
def start(self, __tag: _parser_input_type, __attrs: Dict[_parser_input_type, _parser_input_type]) -> Element: ...
def end(self, __tag: _parser_input_type) -> Element: ...
if sys.version_info >= (3, 8):
class C14NWriterTarget:
def __init__(
self,
write: Callable[[str], Any],
*,
with_comments: bool = ...,
strip_text: bool = ...,
rewrite_prefixes: bool = ...,
qname_aware_tags: Optional[Iterable[str]] = ...,
qname_aware_attrs: Optional[Iterable[str]] = ...,
exclude_attrs: Optional[Iterable[str]] = ...,
exclude_tags: Optional[Iterable[str]] = ...,
) -> None: ...
class XMLParser:
parser: Any
target: Any
# TODO-what is entity used for???
entity: Any
version: str
if sys.version_info >= (3, 8):
def __init__(self, *, target: Any = ..., encoding: Optional[str] = ...) -> None: ...
else:
def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> None: ...
def doctype(self, __name: str, __pubid: str, __system: str) -> None: ...
def __init__(self, html: int = ..., target: Any = ..., encoding: Optional[str] = ...) -> None: ...
def doctype(self, __name: str, __pubid: str, __system: str) -> None: ...
def close(self) -> Any: ...
def feed(self, __data: _parser_input_type) -> None: ...

View File

@@ -22,12 +22,7 @@ class SAXReaderNotAvailable(SAXNotSupportedException): ...
default_parser_list: List[str]
if sys.version_info >= (3, 8):
def make_parser(parser_list: Iterable[str] = ...) -> XMLReader: ...
else:
def make_parser(parser_list: List[str] = ...) -> XMLReader: ...
def make_parser(parser_list: List[str] = ...) -> XMLReader: ...
def parse(source: Union[str, IO[str], IO[bytes]], handler: ContentHandler, errorHandler: ErrorHandler = ...) -> None: ...
def parseString(string: Union[bytes, Text], handler: ContentHandler, errorHandler: Optional[ErrorHandler] = ...) -> None: ...
def _create_parser(parser_name: str) -> XMLReader: ...

View File

@@ -10,19 +10,11 @@ def unescape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ...
def quoteattr(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ...
class XMLGenerator(handler.ContentHandler):
if sys.version_info >= (3, 0):
def __init__(
self,
out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ...,
encoding: str = ...,
short_empty_elements: bool = ...,
) -> None: ...
else:
def __init__(
self,
out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ...,
encoding: Text = ...,
) -> None: ...
def __init__(
self,
out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, SupportsWrite[str]]] = ...,
encoding: Text = ...,
) -> None: ...
def startDocument(self): ...
def endDocument(self): ...
def startPrefixMapping(self, prefix, uri): ...