From 40f2cb6e39c4ad7df52f19d8e4f148c55c54a250 Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Wed, 22 Dec 2021 17:32:35 +0000 Subject: [PATCH] HTMLParser: Add missing stubs for attributes and methods (#6658) Co-authored-by: Alex Waygood --- stdlib/_markupbase.pyi | 13 ++++++++++++- stdlib/html/parser.pyi | 7 ++++++- tests/stubtest_allowlists/py310.txt | 1 - tests/stubtest_allowlists/py3_common.txt | 4 ---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/stdlib/_markupbase.pyi b/stdlib/_markupbase.pyi index 368d32bd5..b942f75ea 100644 --- a/stdlib/_markupbase.pyi +++ b/stdlib/_markupbase.pyi @@ -1,6 +1,17 @@ +import sys +from typing import NoReturn + class ParserBase: def __init__(self) -> None: ... - def error(self, message: str) -> None: ... def reset(self) -> None: ... def getpos(self) -> tuple[int, int]: ... def unknown_decl(self, data: str) -> None: ... + def parse_comment(self, i: int, report: int = ...) -> int: ... # undocumented + def parse_declaration(self, i: int) -> int: ... # undocumented + def parse_marked_section(self, i: int, report: int = ...) -> int: ... # undocumented + def updatepos(self, i: int, j: int) -> int: ... # undocumented + if sys.version_info < (3, 10): + # Removed from ParserBase: https://bugs.python.org/issue31844 + def error(self, message: str) -> NoReturn: ... # undocumented + lineno: int # undocumented + offset: int # undocumented diff --git a/stdlib/html/parser.pyi b/stdlib/html/parser.pyi index fec3f3509..66515cad0 100644 --- a/stdlib/html/parser.pyi +++ b/stdlib/html/parser.pyi @@ -1,5 +1,5 @@ from _markupbase import ParserBase -from typing import Tuple +from typing import Pattern, Tuple class HTMLParser(ParserBase): def __init__(self, *, convert_charrefs: bool = ...) -> None: ... @@ -28,3 +28,8 @@ class HTMLParser(ParserBase): def parse_pi(self, i: int) -> int: ... # undocumented def parse_starttag(self, i: int) -> int: ... # undocumented def set_cdata_mode(self, elem: str) -> None: ... # undocumented + rawdata: str # undocumented + cdata_elem: str | None # undocumented + convert_charrefs: bool # undocumented + interesting: Pattern[str] # undocumented + lasttag: str # undocumented diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index cca4bc2da..43f6a1b20 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -121,7 +121,6 @@ pstats.SortKey.__new__ tkinter.EventType.__new__ # Rest of these errors are new in Python 3.10: -_markupbase.ParserBase.error asyncio.proactor_events._ProactorReadPipeTransport.__init__ distutils.command.bdist_wininst py_compile.main diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index f8eb61238..5c9499053 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -546,10 +546,6 @@ pkgutil.ImpLoader.source # ========== __main__.\w+ _json.encode_basestring -_markupbase.ParserBase.parse_comment -_markupbase.ParserBase.parse_declaration -_markupbase.ParserBase.parse_marked_section -_markupbase.ParserBase.updatepos _thread.LockType.acquire_lock _thread.LockType.locked_lock _thread.LockType.release_lock