Add some missing lxml stub pieces (#436)

This commit is contained in:
Jakub Stasiak
2016-08-04 19:40:13 +02:00
committed by Matthias Kramm
parent de4e87f574
commit a14b1893d9
2 changed files with 73 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
# Any use of `Any` below means I couldn't figure out the type.
import typing
from typing import Any, Dict, List, Tuple, Union
from typing import Any, Dict, List, MutableMapping, Tuple, Union
from typing import SupportsBytes
@@ -21,6 +21,11 @@ class _Element:
def addprevious(self, element: '_Element') -> None:
pass
attrib = ... # type: MutableMapping[str, str]
class ElementBase(_Element):
pass
class _ElementTree:
def write(self,
file: Union[AnyStr, typing.IO],
@@ -100,3 +105,57 @@ def parse(source: Union[AnyStr, typing.IO],
parser: XMLParser = ...,
base_url: AnyStr = ...) -> _ElementTree:
pass
def fromstring(text: AnyStr,
parser: XMLParser = ...,
*,
base_url: AnyStr = ...) -> _Element: ...
def tostring(element_or_tree: Union[_Element, _ElementTree],
encoding: Union[str, type] = ...,
method: str = ...,
xml_declaration: bool = ...,
pretty_print: bool = ...,
with_tail: bool = ...,
standalone: bool = ...,
doctype: str = ...,
exclusive: bool = ...,
with_comments: bool = ...,
inclusive_ns_prefixes: Any = ...) -> AnyStr: ...
class _ErrorLog:
pass
class Error(Exception):
pass
class LxmlError(Error):
def __init__(self, message: Any, error_log: _ErrorLog = ...) -> None: ...
error_log = ... # type: _ErrorLog
class DocumentInvalid(LxmlError):
pass
class LxmlSyntaxError(LxmlError, SyntaxError):
pass
class ParseError(LxmlSyntaxError):
pass
class XMLSyntaxError(ParseError):
pass
class _Validator:
pass
class DTD(_Validator):
def __init__(self,
file: Union[AnyStr, typing.IO] = ...,
*,
external_id: Any = ...) -> None: ...
def assertValid(self, etree: _Element) -> None: ...

13
third_party/3/lxml/objectify.pyi vendored Normal file
View File

@@ -0,0 +1,13 @@
# Hand-written stub, incomplete
from typing import AnyStr
from lxml.etree import ElementBase, XMLParser
class ObjectifiedElement(ElementBase):
pass
def fromstring(text: AnyStr,
parser: XMLParser = ...,
*,
base_url: AnyStr = ...) -> ObjectifiedElement: ...