Add missing argument types for xml.sax stubs (#3706)

* Add missing argument types for xml.sax stubs

* Fix xml typings
This commit is contained in:
Rune Tynan
2020-02-22 00:38:11 -05:00
committed by GitHub
parent 9425e359fc
commit 7d8e2c8546
2 changed files with 16 additions and 8 deletions

View File

@@ -1,18 +1,23 @@
import sys
from typing import Mapping, Text
from typing import Mapping, Text, Optional, Protocol, Union, TextIO
from io import TextIOBase, RawIOBase
from codecs import StreamWriter, StreamReaderWriter
from xml.sax import handler
from xml.sax import xmlreader
class _Writable(Protocol):
def write(self, data: str) -> None: ...
def escape(data: Text, entities: Mapping[Text, Text] = ...) -> Text: ...
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=..., encoding=..., short_empty_elements: bool = ...) -> None: ...
def __init__(self, out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, _Writable]] = ..., encoding: str = ..., short_empty_elements: bool = ...) -> None: ...
else:
def __init__(self, out=..., encoding=...) -> None: ...
def __init__(self, out: Optional[Union[TextIOBase, RawIOBase, StreamWriter, StreamReaderWriter, _Writable]] = ..., encoding: str = ...) -> None: ...
def startDocument(self): ...
def endDocument(self): ...
def startPrefixMapping(self, prefix, uri): ...
@@ -26,7 +31,7 @@ class XMLGenerator(handler.ContentHandler):
def processingInstruction(self, target, data): ...
class XMLFilterBase(xmlreader.XMLReader):
def __init__(self, parent=...) -> None: ...
def __init__(self, parent: Optional[xmlreader.XMLReader] = ...) -> None: ...
def error(self, exception): ...
def fatalError(self, exception): ...
def warning(self, exception): ...

View File

@@ -1,3 +1,6 @@
from typing import Tuple, Mapping, Optional
class XMLReader:
def __init__(self) -> None: ...
def parse(self, source): ...
@@ -16,7 +19,7 @@ class XMLReader:
def setProperty(self, name, value): ...
class IncrementalParser(XMLReader):
def __init__(self, bufsize=...) -> None: ...
def __init__(self, bufsize: int = ...) -> None: ...
def parse(self, source): ...
def feed(self, data): ...
def prepareParser(self, source): ...
@@ -30,7 +33,7 @@ class Locator:
def getSystemId(self): ...
class InputSource:
def __init__(self, system_id=...) -> None: ...
def __init__(self, system_id: Optional[str] = ...) -> None: ...
def setPublicId(self, public_id): ...
def getPublicId(self): ...
def setSystemId(self, system_id): ...
@@ -43,7 +46,7 @@ class InputSource:
def getCharacterStream(self): ...
class AttributesImpl:
def __init__(self, attrs) -> None: ...
def __init__(self, attrs: Mapping[str, str]) -> None: ...
def getLength(self): ...
def getType(self, name): ...
def getValue(self, name): ...
@@ -63,7 +66,7 @@ class AttributesImpl:
def values(self): ...
class AttributesNSImpl(AttributesImpl):
def __init__(self, attrs, qnames) -> None: ...
def __init__(self, attrs: Mapping[Tuple[str, str], str], qnames: Mapping[Tuple[str, str], str]) -> None: ...
def getValueByQName(self, name): ...
def getNameByQName(self, name): ...
def getQNameByName(self, name): ...