Skip to content

Commit

Permalink
Add missing argument types for xml.sax stubs (#3706)
Browse files Browse the repository at this point in the history
* Add missing argument types for xml.sax stubs

* Fix xml typings
  • Loading branch information
CraftSpider authored Feb 22, 2020
1 parent 9425e35 commit 7d8e2c8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
13 changes: 9 additions & 4 deletions stdlib/2and3/xml/sax/saxutils.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
Expand All @@ -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): ...
Expand Down
11 changes: 7 additions & 4 deletions stdlib/2and3/xml/sax/xmlreader.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

from typing import Tuple, Mapping, Optional

class XMLReader:
def __init__(self) -> None: ...
def parse(self, source): ...
Expand All @@ -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): ...
Expand All @@ -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): ...
Expand All @@ -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): ...
Expand All @@ -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): ...
Expand Down

0 comments on commit 7d8e2c8

Please sign in to comment.