From f20e9a79924d608ed90a65cf168a5b94b4bb94fe Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Mon, 12 Feb 2024 12:00:39 -0500 Subject: [PATCH 1/2] Additions to the html5lib stubs to handle type safety warnings in Beautiful Soup's html5lib code. --- stubs/html5lib/html5lib/_inputstream.pyi | 7 +++++-- stubs/html5lib/html5lib/html5parser.pyi | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/stubs/html5lib/html5lib/_inputstream.pyi b/stubs/html5lib/html5lib/_inputstream.pyi index cb3b9c7f6845..a11ce0bcd98f 100644 --- a/stubs/html5lib/html5lib/_inputstream.pyi +++ b/stubs/html5lib/html5lib/_inputstream.pyi @@ -1,5 +1,8 @@ from _typeshed import Incomplete -from typing import Any +from typing import ( + Any, + Tuple, +) spaceCharactersBytes: Any asciiLettersBytes: Any @@ -36,7 +39,7 @@ class HTMLUnicodeInputStream: prevNumCols: int def reset(self) -> None: ... def openStream(self, source): ... - def position(self): ... + def position(self) -> Tuple[int, int]: ... def char(self): ... def readChunk(self, chunkSize: Incomplete | None = None): ... def characterErrorsUCS4(self, data) -> None: ... diff --git a/stubs/html5lib/html5lib/html5parser.pyi b/stubs/html5lib/html5lib/html5parser.pyi index 7ef664ef33cb..e946f7d99485 100644 --- a/stubs/html5lib/html5lib/html5parser.pyi +++ b/stubs/html5lib/html5lib/html5parser.pyi @@ -32,6 +32,7 @@ class HTMLParser: lastPhase: Any beforeRCDataPhase: Any framesetOK: bool + tokenizer: Any def reset(self) -> None: ... @property def documentEncoding(self) -> str | None: ... From 5efae62e6df63a159a753d8346befd1f856bd0f6 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Mon, 12 Feb 2024 12:07:07 -0500 Subject: [PATCH 2/2] Use builtin tuple type instead of importing from typing. --- stubs/html5lib/html5lib/_inputstream.pyi | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/stubs/html5lib/html5lib/_inputstream.pyi b/stubs/html5lib/html5lib/_inputstream.pyi index a11ce0bcd98f..992aaa2f07a6 100644 --- a/stubs/html5lib/html5lib/_inputstream.pyi +++ b/stubs/html5lib/html5lib/_inputstream.pyi @@ -1,8 +1,5 @@ from _typeshed import Incomplete -from typing import ( - Any, - Tuple, -) +from typing import Any spaceCharactersBytes: Any asciiLettersBytes: Any @@ -39,7 +36,7 @@ class HTMLUnicodeInputStream: prevNumCols: int def reset(self) -> None: ... def openStream(self, source): ... - def position(self) -> Tuple[int, int]: ... + def position(self) -> tuple[int, int]: ... def char(self): ... def readChunk(self, chunkSize: Incomplete | None = None): ... def characterErrorsUCS4(self, data) -> None: ...