From 9db84e7ffecf8b6e551a3e7a04212e19595293db Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 27 Jan 2016 17:30:36 -0800 Subject: [PATCH 1/2] Add stubs for HTMLParser, html.parser, and six.moves.html_parser. --- stdlib/2.7/HTMLParser.pyi | 28 ++++++++++++++++++++++++++ stdlib/2.7/markupbase.pyi | 9 +++++++++ stdlib/3/_markupbase.pyi | 9 +++++++++ stdlib/3/html/__init__.pyi | 4 ++++ stdlib/3/html/parser.pyi | 28 ++++++++++++++++++++++++++ third_party/2.7/six/moves/__init__.pyi | 1 + third_party/3/six/moves/__init__.pyi | 1 + 7 files changed, 80 insertions(+) create mode 100644 stdlib/2.7/HTMLParser.pyi create mode 100644 stdlib/2.7/markupbase.pyi create mode 100644 stdlib/3/_markupbase.pyi create mode 100644 stdlib/3/html/parser.pyi diff --git a/stdlib/2.7/HTMLParser.pyi b/stdlib/2.7/HTMLParser.pyi new file mode 100644 index 000000000..ae6c3099a --- /dev/null +++ b/stdlib/2.7/HTMLParser.pyi @@ -0,0 +1,28 @@ +from typing import List, Tuple, AnyStr +from markupbase import ParserBase + +class HTMLParser(ParserBase): + def __init__(self, *args, convert_charrefs: bool) -> None: ... + def feed(self, feed: AnyStr) -> None: ... + def close(self) -> None: ... + def reset(self) -> None: ... + + def get_starttag_text(self) -> AnyStr: ... + def set_cdata_mode(self, AnyStr) -> None: ... + def clear_cdata_mode(self) -> None: ... + + def handle_startendtag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ... + def handle_starttag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ... + def handle_endtag(self, tag: AnyStr): ... + def handle_charref(self, name: AnyStr): ... + def handle_entityref(self, name: AnyStr): ... + def handle_data(self, data: AnyStr): ... + def handle_comment(self, data: AnyStr): ... + def handle_decl(self, decl: AnyStr): ... + def handle_pi(self, data: AnyStr): ... + + def unknown_decl(self, data: AnyStr): ... + + def unescape(self, s: AnyStr) -> AnyStr: ... + +class HTMLParseError(Exception): ... diff --git a/stdlib/2.7/markupbase.pyi b/stdlib/2.7/markupbase.pyi new file mode 100644 index 000000000..129b49b90 --- /dev/null +++ b/stdlib/2.7/markupbase.pyi @@ -0,0 +1,9 @@ +from typing import Tuple + +class ParserBase(object): + def __init__(self) -> None: ... + def error(self, message: str) -> None: ... + def reset(self) -> None: ... + def getpos(self) -> Tuple[int, int]: ... + + def unkown_decl(self, data: str) -> None: ... diff --git a/stdlib/3/_markupbase.pyi b/stdlib/3/_markupbase.pyi new file mode 100644 index 000000000..129b49b90 --- /dev/null +++ b/stdlib/3/_markupbase.pyi @@ -0,0 +1,9 @@ +from typing import Tuple + +class ParserBase(object): + def __init__(self) -> None: ... + def error(self, message: str) -> None: ... + def reset(self) -> None: ... + def getpos(self) -> Tuple[int, int]: ... + + def unkown_decl(self, data: str) -> None: ... diff --git a/stdlib/3/html/__init__.pyi b/stdlib/3/html/__init__.pyi index e69de29bb..c8577ea2e 100644 --- a/stdlib/3/html/__init__.pyi +++ b/stdlib/3/html/__init__.pyi @@ -0,0 +1,4 @@ +from typing import AnyStr + +def escape(s: AnyStr, quote: bool) -> AnyStr: ... +def unescape(s: AnyStr) -> AnyStr: ... diff --git a/stdlib/3/html/parser.pyi b/stdlib/3/html/parser.pyi new file mode 100644 index 000000000..4328f3f77 --- /dev/null +++ b/stdlib/3/html/parser.pyi @@ -0,0 +1,28 @@ +from typing import AnyStr, List, Tuple +from _markupbase import ParserBase + +class HTMLParser(ParserBase): + def __init__(self, *args, convert_charrefs: bool) -> None: ... + def feed(self, feed: AnyStr) -> None: ... + def close(self) -> None: ... + def reset(self) -> None: ... + + def get_starttag_text(self) -> AnyStr: ... + def set_cdata_mode(self, AnyStr) -> None: ... + def clear_cdata_mode(self) -> None: ... + + def handle_startendtag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ... + def handle_starttag(self, tag: AnyStr, attrs: List[Tuple[AnyStr, AnyStr]]): ... + def handle_endtag(self, tag: AnyStr): ... + def handle_charref(self, name: AnyStr): ... + def handle_entityref(self, name: AnyStr): ... + def handle_data(self, data: AnyStr): ... + def handle_comment(self, data: AnyStr): ... + def handle_decl(self, decl: AnyStr): ... + def handle_pi(self, data: AnyStr): ... + + def unknown_decl(self, data: AnyStr): ... + + def unescape(self, s: AnyStr) -> AnyStr: ... + +class HTMLParseError(Exception): ... diff --git a/third_party/2.7/six/moves/__init__.pyi b/third_party/2.7/six/moves/__init__.pyi index aef863dec..2329d9156 100644 --- a/third_party/2.7/six/moves/__init__.pyi +++ b/third_party/2.7/six/moves/__init__.pyi @@ -20,6 +20,7 @@ from __builtin__ import xrange as xrange from itertools import izip as zip from itertools import izip_longest as zip_longest import six.moves.cPickle as cPickle +import HTMLParser as html_parser import six.moves.urllib_parse as urllib_parse import six.moves.urllib_error as urllib_error diff --git a/third_party/3/six/moves/__init__.pyi b/third_party/3/six/moves/__init__.pyi index 00dedd754..e7d36321b 100644 --- a/third_party/3/six/moves/__init__.pyi +++ b/third_party/3/six/moves/__init__.pyi @@ -23,6 +23,7 @@ from builtins import range as xrange from builtins import zip as zip from itertools import zip_longest as zip_longest import six.moves.cPickle as cPickle +import html.parser as html_parser import six.moves.urllib_parse as urllib_parse import six.moves.urllib_error as urllib_error From 5f8358f7e36ead636ca4883b3d95361bc0d3108f Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 27 Jan 2016 17:44:07 -0800 Subject: [PATCH 2/2] Add html_entities import stubs to six.moves. --- third_party/2.7/six/moves/__init__.pyi | 1 + third_party/3/six/moves/__init__.pyi | 1 + 2 files changed, 2 insertions(+) diff --git a/third_party/2.7/six/moves/__init__.pyi b/third_party/2.7/six/moves/__init__.pyi index 2329d9156..1347e7510 100644 --- a/third_party/2.7/six/moves/__init__.pyi +++ b/third_party/2.7/six/moves/__init__.pyi @@ -21,6 +21,7 @@ from itertools import izip as zip from itertools import izip_longest as zip_longest import six.moves.cPickle as cPickle import HTMLParser as html_parser +import htmlentitydefs as html_entities import six.moves.urllib_parse as urllib_parse import six.moves.urllib_error as urllib_error diff --git a/third_party/3/six/moves/__init__.pyi b/third_party/3/six/moves/__init__.pyi index e7d36321b..4f41143e9 100644 --- a/third_party/3/six/moves/__init__.pyi +++ b/third_party/3/six/moves/__init__.pyi @@ -24,6 +24,7 @@ from builtins import zip as zip from itertools import zip_longest as zip_longest import six.moves.cPickle as cPickle import html.parser as html_parser +import html.entities as html_entities import six.moves.urllib_parse as urllib_parse import six.moves.urllib_error as urllib_error