mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-10 05:22:23 +08:00
apply black and isort (#4287)
* apply black and isort * move some type ignores
This commit is contained in:
@@ -16,5 +16,4 @@ class NodeFilter:
|
||||
SHOW_DOCUMENT_TYPE: int
|
||||
SHOW_DOCUMENT_FRAGMENT: int
|
||||
SHOW_NOTATION: int
|
||||
|
||||
def acceptNode(self, node) -> int: ...
|
||||
|
||||
@@ -12,7 +12,6 @@ class Node:
|
||||
DOCUMENT_FRAGMENT_NODE: int
|
||||
NOTATION_NODE: int
|
||||
|
||||
|
||||
# ExceptionCode
|
||||
INDEX_SIZE_ERR: int
|
||||
DOMSTRING_SIZE_ERR: int
|
||||
@@ -31,10 +30,8 @@ NAMESPACE_ERR: int
|
||||
INVALID_ACCESS_ERR: int
|
||||
VALIDATION_ERR: int
|
||||
|
||||
|
||||
class DOMException(Exception):
|
||||
code: int
|
||||
|
||||
def __init__(self, *args, **kw) -> None: ...
|
||||
def _get_code(self) -> int: ...
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import sys
|
||||
from typing import Union, Optional, Callable
|
||||
from typing import Callable, Optional, Union
|
||||
from xml.etree.ElementTree import Element
|
||||
|
||||
XINCLUDE: str
|
||||
@@ -14,6 +14,12 @@ def default_loader(href: Union[str, bytes, int], parse: str, encoding: Optional[
|
||||
# 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: ...
|
||||
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: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Stubs for xml.etree.ElementPath (Python 3.4)
|
||||
|
||||
from typing import Pattern, Dict, Generator, Tuple, List, Union, TypeVar, Callable, Optional
|
||||
from typing import Callable, Dict, Generator, List, Optional, Pattern, Tuple, TypeVar, Union
|
||||
from xml.etree.ElementTree import Element
|
||||
|
||||
xpath_tokenizer_re: Pattern[str]
|
||||
@@ -25,9 +25,11 @@ class _SelectorContext:
|
||||
root: Element
|
||||
def __init__(self, root: Element) -> None: ...
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def iterfind(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ...
|
||||
def find(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> Optional[Element]: ...
|
||||
def findall(elem: Element, path: str, namespaces: Optional[Dict[str, str]] = ...) -> List[Element]: ...
|
||||
def findtext(elem: Element, path: str, default: Optional[_T] = ..., namespaces: Optional[Dict[str, str]] = ...) -> Union[_T, str]: ...
|
||||
def findtext(
|
||||
elem: Element, path: str, default: Optional[_T] = ..., namespaces: Optional[Dict[str, str]] = ...
|
||||
) -> Union[_T, str]: ...
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import sys
|
||||
from typing import (
|
||||
IO,
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Generator,
|
||||
IO,
|
||||
ItemsView,
|
||||
Iterable,
|
||||
Iterator,
|
||||
@@ -18,10 +19,11 @@ from typing import (
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
from _typeshed import AnyPath, FileDescriptor, SupportsWrite
|
||||
import sys
|
||||
|
||||
from typing_extensions import Literal
|
||||
|
||||
from _typeshed import AnyPath, FileDescriptor, SupportsWrite
|
||||
|
||||
VERSION: str
|
||||
|
||||
class ParseError(SyntaxError):
|
||||
@@ -30,7 +32,7 @@ class ParseError(SyntaxError):
|
||||
|
||||
def iselement(element: object) -> bool: ...
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
# Type for parser inputs. Parser will accept any unicode/str/bytes and coerce,
|
||||
# and this is true in py2 and py3 (even fromstringlist() in python3 can be
|
||||
@@ -93,17 +95,33 @@ class Element(MutableSequence[Element]):
|
||||
attrib: Dict[_str_result_type, _str_result_type]
|
||||
text: Optional[_str_result_type]
|
||||
tail: Optional[_str_result_type]
|
||||
def __init__(self, tag: Union[_str_argument_type, Callable[..., Element]], attrib: Dict[_str_argument_type, _str_argument_type] = ..., **extra: _str_argument_type) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
tag: Union[_str_argument_type, Callable[..., Element]],
|
||||
attrib: Dict[_str_argument_type, _str_argument_type] = ...,
|
||||
**extra: _str_argument_type,
|
||||
) -> None: ...
|
||||
def append(self, __subelement: Element) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def copy(self) -> Element: ...
|
||||
def extend(self, __elements: Iterable[Element]) -> None: ...
|
||||
def find(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Optional[Element]: ...
|
||||
def findall(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> List[Element]: ...
|
||||
def find(
|
||||
self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
|
||||
) -> Optional[Element]: ...
|
||||
def findall(
|
||||
self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
|
||||
) -> List[Element]: ...
|
||||
@overload
|
||||
def findtext(self, path: _str_argument_type, default: None = ..., namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Optional[_str_result_type]: ...
|
||||
def findtext(
|
||||
self,
|
||||
path: _str_argument_type,
|
||||
default: None = ...,
|
||||
namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...,
|
||||
) -> Optional[_str_result_type]: ...
|
||||
@overload
|
||||
def findtext(self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Union[_T, _str_result_type]: ...
|
||||
def findtext(
|
||||
self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
|
||||
) -> Union[_T, _str_result_type]: ...
|
||||
@overload
|
||||
def get(self, key: _str_argument_type, default: None = ...) -> Optional[_str_result_type]: ...
|
||||
@overload
|
||||
@@ -116,7 +134,9 @@ class Element(MutableSequence[Element]):
|
||||
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(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> List[Element]: ...
|
||||
def iterfind(
|
||||
self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
|
||||
) -> List[Element]: ...
|
||||
def itertext(self) -> Generator[_str_result_type, None, None]: ...
|
||||
def keys(self) -> KeysView[_str_result_type]: ...
|
||||
def makeelement(self, __tag: _str_argument_type, __attrib: Dict[_str_argument_type, _str_argument_type]) -> Element: ...
|
||||
@@ -134,8 +154,12 @@ class Element(MutableSequence[Element]):
|
||||
@overload
|
||||
def __setitem__(self, s: slice, o: Iterable[Element]) -> None: ...
|
||||
|
||||
|
||||
def SubElement(parent: Element, tag: _str_argument_type, attrib: Dict[_str_argument_type, _str_argument_type] = ..., **extra: _str_argument_type) -> Element: ...
|
||||
def SubElement(
|
||||
parent: Element,
|
||||
tag: _str_argument_type,
|
||||
attrib: Dict[_str_argument_type, _str_argument_type] = ...,
|
||||
**extra: _str_argument_type,
|
||||
) -> Element: ...
|
||||
def Comment(text: Optional[_str_argument_type] = ...) -> Element: ...
|
||||
def ProcessingInstruction(target: _str_argument_type, text: Optional[_str_argument_type] = ...) -> Element: ...
|
||||
|
||||
@@ -151,17 +175,46 @@ class ElementTree:
|
||||
def parse(self, source: _file_or_filename, parser: Optional[XMLParser] = ...) -> Element: ...
|
||||
def iter(self, tag: Optional[_str_argument_type] = ...) -> Generator[Element, None, None]: ...
|
||||
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]: ...
|
||||
def find(
|
||||
self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
|
||||
) -> Optional[Element]: ...
|
||||
@overload
|
||||
def findtext(self, path: _str_argument_type, default: None = ..., namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Optional[_str_result_type]: ...
|
||||
def findtext(
|
||||
self,
|
||||
path: _str_argument_type,
|
||||
default: None = ...,
|
||||
namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...,
|
||||
) -> Optional[_str_result_type]: ...
|
||||
@overload
|
||||
def findtext(self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> Union[_T, _str_result_type]: ...
|
||||
def findall(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> List[Element]: ...
|
||||
def iterfind(self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...) -> List[Element]: ...
|
||||
def findtext(
|
||||
self, path: _str_argument_type, default: _T, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
|
||||
) -> Union[_T, _str_result_type]: ...
|
||||
def findall(
|
||||
self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
|
||||
) -> List[Element]: ...
|
||||
def iterfind(
|
||||
self, path: _str_argument_type, namespaces: Optional[Dict[_str_argument_type, _str_argument_type]] = ...
|
||||
) -> List[Element]: ...
|
||||
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: ...
|
||||
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: ...
|
||||
@@ -197,7 +250,6 @@ if sys.version_info >= (3, 8):
|
||||
default_namespace: Optional[_str_argument_type] = ...,
|
||||
short_empty_elements: bool = ...,
|
||||
) -> Any: ...
|
||||
|
||||
@overload
|
||||
def tostringlist(
|
||||
element: Element,
|
||||
@@ -231,24 +283,37 @@ if sys.version_info >= (3, 8):
|
||||
|
||||
elif sys.version_info >= (3,):
|
||||
@overload
|
||||
def tostring(element: Element, encoding: None = ..., method: Optional[str] = ..., *, short_empty_elements: bool = ...) -> bytes: ...
|
||||
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: ...
|
||||
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]: ...
|
||||
|
||||
@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 dump(elem: Element) -> 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]]: ...
|
||||
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:
|
||||
@@ -298,7 +363,6 @@ if sys.version_info >= (3, 8):
|
||||
exclude_tags: Optional[Iterable[str]] = ...,
|
||||
) -> None: ...
|
||||
|
||||
|
||||
class XMLParser:
|
||||
parser: Any
|
||||
target: TreeBuilder
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
from typing import Any, Iterable, List, NoReturn, Optional, Text, Union, IO
|
||||
|
||||
import sys
|
||||
import xml.sax
|
||||
from xml.sax.xmlreader import InputSource, Locator
|
||||
from typing import IO, Any, Iterable, List, NoReturn, Optional, Text, Union
|
||||
from xml.sax.handler import ContentHandler, ErrorHandler
|
||||
from xml.sax.xmlreader import InputSource, Locator
|
||||
|
||||
class SAXException(Exception):
|
||||
def __init__(self, msg: str, exception: Optional[Exception] = ...) -> None: ...
|
||||
@@ -26,13 +25,18 @@ default_parser_list: List[str]
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
def make_parser(parser_list: Iterable[str] = ...) -> xml.sax.xmlreader.XMLReader: ...
|
||||
|
||||
else:
|
||||
def make_parser(parser_list: List[str] = ...) -> xml.sax.xmlreader.XMLReader: ...
|
||||
|
||||
def parse(source: Union[str, IO[str], IO[bytes]], handler: xml.sax.handler.ContentHandler,
|
||||
errorHandler: xml.sax.handler.ErrorHandler = ...) -> None: ...
|
||||
|
||||
def parseString(string: Union[bytes, Text], handler: xml.sax.handler.ContentHandler,
|
||||
errorHandler: Optional[xml.sax.handler.ErrorHandler] = ...) -> None: ...
|
||||
|
||||
def parse(
|
||||
source: Union[str, IO[str], IO[bytes]],
|
||||
handler: xml.sax.handler.ContentHandler,
|
||||
errorHandler: xml.sax.handler.ErrorHandler = ...,
|
||||
) -> None: ...
|
||||
def parseString(
|
||||
string: Union[bytes, Text],
|
||||
handler: xml.sax.handler.ContentHandler,
|
||||
errorHandler: Optional[xml.sax.handler.ErrorHandler] = ...,
|
||||
) -> None: ...
|
||||
def _create_parser(parser_name: str) -> xml.sax.xmlreader.XMLReader: ...
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import sys
|
||||
from typing import Mapping, Text, Optional, Union, TextIO
|
||||
from io import TextIOBase, RawIOBase
|
||||
from codecs import StreamWriter, StreamReaderWriter
|
||||
from _typeshed import SupportsWrite
|
||||
from codecs import StreamReaderWriter, StreamWriter
|
||||
from io import RawIOBase, TextIOBase
|
||||
from typing import Mapping, Optional, Text, TextIO, Union
|
||||
from xml.sax import handler, xmlreader
|
||||
|
||||
from xml.sax import handler
|
||||
from xml.sax import xmlreader
|
||||
from _typeshed import SupportsWrite
|
||||
|
||||
def escape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ...
|
||||
def unescape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ...
|
||||
@@ -13,9 +12,18 @@ 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: ...
|
||||
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): ...
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
from typing import Tuple, Mapping, Optional
|
||||
from typing import Mapping, Optional, Tuple
|
||||
|
||||
class XMLReader:
|
||||
def __init__(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user